Batch file 批处理传输的自动运行脚本

Batch file 批处理传输的自动运行脚本,batch-file,Batch File,我一点也不是程序员。我先看了几篇帖子,然后问是否有适合我这个看似简单的问题的帖子。不幸的是,我没有找到任何解释我所寻找的 我的问题是: 我希望每个月都能给我妈妈发一个装满照片的U盘。她一点也不懂电脑。 我希望这个过程是简单的,我的家庭其他成员也可以复制。 我在妈妈的电脑上做了一个目录C:\家庭照片。在那里,她可以轻松地打开所有的图片来查看它们。 每个月我都想给她寄更多的照片(很多)。我想把它们都放在一个USB上,当她把它插入时,它们会自动从USB传输到上面提到的驱动器C上的指定文件夹 我们都使用

我一点也不是程序员。我先看了几篇帖子,然后问是否有适合我这个看似简单的问题的帖子。不幸的是,我没有找到任何解释我所寻找的

我的问题是: 我希望每个月都能给我妈妈发一个装满照片的U盘。她一点也不懂电脑。 我希望这个过程是简单的,我的家庭其他成员也可以复制。 我在妈妈的电脑上做了一个目录C:\家庭照片。在那里,她可以轻松地打开所有的图片来查看它们。 每个月我都想给她寄更多的照片(很多)。我想把它们都放在一个USB上,当她把它插入时,它们会自动从USB传输到上面提到的驱动器C上的指定文件夹

我们都使用Windows 10,据我所知,我的6个兄弟姐妹也使用Windows 10。这样,我的家人每个月都可以给她发USB

这可能吗?我很想学习如何在那里创建它,让它对妈妈来说很简单:) 提前感谢,,
Me

自Windows 7以来,自动运行不再可用,因此您可以在桌面中放置一个批处理文件,并告诉她插入USB驱动器,然后按顺序运行桌面脚本

代码如下所示:

@echo off
setlocal
:=============================================================
:OPTIONS - you can change these values

set _SourcePath=C:\Family Pictures
set _DestPath=X:\Family Pictures\Mama

:=============================================================
set _LogPath=%_DestPath%\_log.txt

echo/
echo/This will copy the family files:
echo/ FROM: %_SourcePath% 
echo/ TO: %_DestPath%
echo/

:prompt1
  set /p msgbox=Continue? [Y/N]
  if /i "%msgbox%"=="n" (echo/"Aborted..." &goto:end)
  if /i "%msgbox%"=="y" goto:step1
goto:prompt1

:step1
  if exist "%_DestPath%\" goto:step2
  echo/
  echo Folder %_DestPath% does not exist.
  echo/
  :prompt2
    set /p msgbox=Create folder? [Y/N]
    if /i "%msgbox%"=="n" (echo/"Aborted..." &goto:end)
    if /i "%msgbox%"=="y" goto:CreateFolder
  goto:prompt2

:CreateFolder
  md "%_DestPath%"
  echo %errorlevel%
  if not %ERRORLEVEL%==0 (echo/Aborting: error while creating destination folder &goto:end)

:step2
  echo/
  echo/ Copying files...
  echo/
  xcopy "%_SourcePath%" "%_DestPath%" /Z /Y /E > "%_LogPath%"
  if %ERRORLEVEL%==0 goto:DeleteLog
  :prompt3
    set /p msgbox=There were errors copying the files. View log file? [Y/N]
    if /i "%msgbox%"=="n" goto:DeleteLog
    if /i "%msgbox%"=="y" (notepad "%_LogPath%" &goto:end)
  goto:prompt3

:DeleteLog
  del "%_LogPath%"

:end
endlocal
注:

  • 将:选项下的路径更改为所需路径

自Windows 7以来,自动运行不再可用,因此您可以在桌面中放置一个批处理文件,告诉她插入USB驱动器,然后按顺序运行桌面脚本

代码如下所示:

@echo off
setlocal
:=============================================================
:OPTIONS - you can change these values

set _SourcePath=C:\Family Pictures
set _DestPath=X:\Family Pictures\Mama

:=============================================================
set _LogPath=%_DestPath%\_log.txt

echo/
echo/This will copy the family files:
echo/ FROM: %_SourcePath% 
echo/ TO: %_DestPath%
echo/

:prompt1
  set /p msgbox=Continue? [Y/N]
  if /i "%msgbox%"=="n" (echo/"Aborted..." &goto:end)
  if /i "%msgbox%"=="y" goto:step1
goto:prompt1

:step1
  if exist "%_DestPath%\" goto:step2
  echo/
  echo Folder %_DestPath% does not exist.
  echo/
  :prompt2
    set /p msgbox=Create folder? [Y/N]
    if /i "%msgbox%"=="n" (echo/"Aborted..." &goto:end)
    if /i "%msgbox%"=="y" goto:CreateFolder
  goto:prompt2

:CreateFolder
  md "%_DestPath%"
  echo %errorlevel%
  if not %ERRORLEVEL%==0 (echo/Aborting: error while creating destination folder &goto:end)

:step2
  echo/
  echo/ Copying files...
  echo/
  xcopy "%_SourcePath%" "%_DestPath%" /Z /Y /E > "%_LogPath%"
  if %ERRORLEVEL%==0 goto:DeleteLog
  :prompt3
    set /p msgbox=There were errors copying the files. View log file? [Y/N]
    if /i "%msgbox%"=="n" goto:DeleteLog
    if /i "%msgbox%"=="y" (notepad "%_LogPath%" &goto:end)
  goto:prompt3

:DeleteLog
  del "%_LogPath%"

:end
endlocal
注:

  • 将:选项下的路径更改为所需路径

上次我检查USB设备的自动运行时,Windows 7已禁用。这是否意味着这不可能?问得好,我想知道答案。因为没有代码示例等原因,我就要否决投票。但问题很简单。我理解YoYo,但我不是一个“程序员”,只是一个对让我妈妈的生活更快乐感兴趣的家伙:)你可以安装云同步服务,如dropbox、mega、sync.com等。。。在每台计算机上。这样就不会那么麻烦了。上次我检查USB设备的自动运行是从Windows 7开始禁用的。那么这是否意味着这不可能?问得好,我对答案很好奇。因为没有代码示例等原因,我就要否决投票。但问题很简单。我理解YoYo,但我不是一个“程序员”,只是一个对让我妈妈的生活更快乐感兴趣的家伙:)你可以安装云同步服务,如dropbox、mega、sync.com等。。。在每台计算机上。这样就不会那么麻烦了。