Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 批处理-以下在批处理参数替换中使用的path运算符无效-存档Google Chrome下载文件夹_Batch File - Fatal编程技术网

Batch file 批处理-以下在批处理参数替换中使用的path运算符无效-存档Google Chrome下载文件夹

Batch file 批处理-以下在批处理参数替换中使用的path运算符无效-存档Google Chrome下载文件夹,batch-file,Batch File,A在我的windows 7 64位pc上的Google Chrome Downloads文件夹中创建了一个批处理文件,每月使用任务计划程序进行归档。 它应该将文件从sertain文件类型移动到另一个文件夹,如果它上个月没有被修改的话。文件应移动到的文件夹取决于上次修改的日期 因此,我制作了以下批处理文件: @ECHO OFF CD C:\Users\Dagan\Downloads FORFILES /m (DIR (FOR %%G IN (*.doc *.pdf) do echo %%G) /A

A在我的windows 7 64位pc上的Google Chrome Downloads文件夹中创建了一个批处理文件,每月使用任务计划程序进行归档。 它应该将文件从sertain文件类型移动到另一个文件夹,如果它上个月没有被修改的话。文件应移动到的文件夹取决于上次修改的日期

因此,我制作了以下批处理文件:

@ECHO OFF CD C:\Users\Dagan\Downloads FORFILES /m (DIR (FOR %%G IN (*.doc *.pdf) do echo %%G) /A /O:D /T:C /B /D) /c "FOR %Q IN (@path) DO ((SET year=%%~tG ) && (SET year=%year~6,4%) && (SET month=%%~tG) && (SET month=%month~3,2%) && (MOVE %%G "C:\Users\Dagan\DownloadArchives\"%year%"\"%month%"\") && (SET year=) && (SET month=))" /d -31 CD C:\Users\Dagan\Desktop 但它不工作,我得到以下错误:

The following usage of the path operator in batch-parameter substitution is invalid: %~tG ) && (SET year=%year~6,4%) && (SET month=% %~tG) && (SET month=%month~3,2%) && (MOVE %%G "C:\Users\Dagan\DownloadArchives\"% year%"\"%month%"\") && (SET year=) && (SET month=))" /d -31 For valid formats type CALL /? or FOR /? ☺ is not expected at this point. 有人能帮我吗

PS:这是我的批处理文件,但现在已格式化,以便更好地阅读:

@ECHO OFF CD C:\Users\Dagan\Downloads FORFILES /m ( DIR ( FOR %%G IN ( *.doc *.pdf ) do echo %%G ) /A /O:D /T:C /B /D ) /c " FOR %Q IN (@path) DO ( (SET year=%%~tG ) && (SET year=%year~6,4%) && (SET month=%%~tG) && (SET month=%month~3,2%) && (MOVE %%G "C:\Users\Dagan\DownloadArchives\"%year%"\"%month%"\") && (SET year=) && (SET month=) ) " /d -31 CD C:\Users\Dagan\Desktop
我认为path变量中的“@”是问题所在。我不认为CMD用Perl数组语法扩展了路径。

更可读的批处理文件实际运行了吗?对我来说,它给出了一个错误:找不到类型的文件。