I have a bunch of *.mp4 & *.jpg files created on an hourly/daily basis, which use the file structure below:
-- before:
c:\video\2017-10-15\21hour\jpg\12.13.15[M][0@0][0].jpg
c:\video\2017-10-15\21hour\mp4\12.13.01-12.14.32[M][0@0][0].mp4
c:\video\2017-10-18\16hour\jpg\21.42.31[M][0@0][0].jpg
c:\video\2017-10-18\16hour\mp4\21.42.31-21.45.38[M][0@0][0].mp4
I want all the *.jpg & *.mp4 files to get moved to c:\video\ & also completely ditch the old name for 'date_time' + extension, similar to below:
-- after:
c:\video\2017-10-15_12.13.15.jpg
c:\video\2017-10-15_12.13.01-12.14.32.mp4
c:\video\2017-10-18_21.42.31.jpg
c:\video\2017-10-18_21.42.31-21.45.38.mp4
I discovered ForFiles, and was able to use the /s to recursively search all subfolders & move the *.mp4 & *.jpg to a single location:
forfiles /p c:\video\ /s /m *.mp4 /c "cmd /c move @PATH c:\video\"
forfiles /p c:\video\ /s /m *.jpg /c "cmd /c move @PATH c:\video\"
Now for the renaming, at this point I can almost taste victory as this gives me the desired filename output:
forfiles /p c:\video\ /s /m *.mp4 /c "cmd /c echo @[email protected]"
forfiles /p c:\video\ /s /m *.jpg /c "cmd /c echo @[email protected]"
But when I replace echo with either ren/rename/move, I get errors: The system cannot find the path specified. The syntax of the command is incorrect.
But the error only happens when I'm using @FDATE and/or @FTIME. These variables all work fine: @FNAME, @ISDIR, @FSIZE
forfiles /p c:\video\ /m *.mp4 /c "cmd /c ren @FILE @ISDIR.@EXT"
forfiles /p c:\video\ /m *.mp4 /c "cmd /c rename @FILE @FSIZE.@EXT"
forfiles /p c:\video\ /m *.mp4 /c "cmd /c move @FILE @EXT.@EXT"
Once I get the renaming part to work, I will combine both the move & rename into one command... But I can't figure out why @FDATE & @FTIME won't take, is there something wrong with my syntax, or is this just something ForFiles doesn't allow?
Move
accepts a new file name for the destination, so I would suggest that you perform both tasks with the same routine. You could perform the rename first, but do not move all of your files before the rename. If you have already done so then both-- before:
and-- after:
have changed and your question requires updating accordingly. – Compo