简体   繁体   中英

Batch file “for” command

Need to be able to "schedule" a command line action using windows scheduler.

This is my command:

for /r C:\Users\bob\Downloads\Done\ %f in (*) do @move "%f" C:\Users\bob\Downloads\Done\

It flattens all files into the main folder.

The "for" command does not work as in a scheduler but is working in cmd.exe

I need a batch file or other code so that I can use the scheduler.

I read these, but I'm just not that cool: How to copy files from folder tree dropping all the folders with Robocopy?

How does "FOR" work in cmd batch file?

Take your above code and save it in a .bat file. The only change you need to make, is that percents (%) need to be doubled-up when run inside a batch file.

for /r C:\Users\bob\Downloads\Done\ %%f in (*) do (
    @move "%%f" C:\Users\bob\Downloads\Done\
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM