简体   繁体   中英

how to combine forfiles, copy, and @fname?

This command is supposed to copy multiple files from a static source folder into each folder for a set of saved web pages:

forfiles /m *.htm /c "cmd /c copy /y _core/*.* @fname_files"

However, each call fails with a status of, "The system cannot find the file specified."

If this is tried:

forfiles /m *.htm /c "cmd /c copy /y 0x22_core/*.*0x22 @fname_files"

the status displayed shows the name of each source file and the same error message.

I've also tried adding setlocal / endlocal around the call but it still fails.

Searching on the web brought lots of discussions but nothing showing forfiles , cmd , and copying into a destination directory using @fname .

Would someone with deeper knowledge of batch scripting "fix" this line so it works as intended?

If I understand correctly what you are trying to do :

1)You might be getting "The system cannot find the file specified." because the directory _core is not in the same directory as the *.htm files

2)In order to copy the *.htm files into each @fname_files folder, you must create the folder first. Here is the command line with mkdir added :

forfiles /m *.htm /c "cmd /c mkdir @fname_files & copy /y _core\*.* @fname_files"

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