非递归文件移动与多个通配符

huangapple go评论58阅读模式
英文:

Non-recursive file move with multiple Wildcards

问题

如何修改此代码以使其非递归?

FOR /R %pathold% %%G in (*.tif *.tiff *.jpg *.jpeg *.pdf) do (
    move "%%G" %pathnew%>NUL
    echo %%G
)

我尝试使用 ForFiles,但它不支持多个通配符。

ForFiles /P %pathold% /M *.tif *.tiff *.jpg *.jpeg *.pdf /C "move @path %pathnew%"

错误:无效的参数/选项 - '* .tiff'。

英文:

How would I alter this code to make it non-recursive?

FOR /R %pathold% %%G in (*.tif *.tiff *.jpg *.jpeg *.pdf) do (
    move "%%G" %pathnew%>NUL
    echo %%G
)

I tried using ForFiles, but it doesn't support multiple Wildcards.

ForFiles /P %pathold% /M *.tif *.tiff *.jpg *.jpeg *.pdf /C "move @path %pathnew%"

>ERROR: Invalid argument / option - '* .tiff'.

答案1

得分: 0

为了只使用根目录,从上面的代码中删除/R %pathold%,使其看起来像这样:

FOR %%G in (*.tif *.tiff *.jpg *.jpeg *.pdf) do (
move "%%G" %pathnew%>NUL
echo Moving %%G
)

重要注意事项
你必须在你想要移动的目录中。
你可以使用cd %oldpath%pushd %oldpath%来实现这一点,例如。

英文:

So in order to use only the root Directory remove the /R %pathold% from the Code above so it looks like this:

FOR %%G in (*.tif *.tiff *.jpg *.jpeg *.pdf) do (
move "%%G" %pathnew%>NUL
echo Moving %%G
)

Important to note:
You have to be in the Directory you wan't to move from.
You can do this with cd %oldpath% or pushd %oldpath% for example.

huangapple
  • 本文由 发表于 2020年1月3日 19:16:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/59577630.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定