0

My photo importing program puts the backup copy of the photos in a folder labeled "imported on DATE". These folders are created as subfolders of the desired location folder. I have many such "imported" folders under multiple layers of folders. An example would be:

C:\pictures\all photos 2013\01jan13\imported on jan 18.

Is there a way to scan down from the pictures folder through each of its subfolders and have the program move any files in an "imported on" folder to the folder above it? Sorry if this is confusing!

Thanks for any help

1 Answer 1

0

This works in Windows 7; I don’t know about other versions:

for /r C:\pictures %F in (*.*) do move %F %F\..\..

Notes:

  • for /r C:\pictures %F in (*.*) do … performs the following statement once for each file under C:\pictures, recursively, with %F set to the filename.
  • move moves a file.
  • Here it gets tricky.  You know that cd .. takes you up one level.  Well, it turns out you can say \Users\rshonaker\Documents\fubar.doc\.., and it will refer to \Users\rshonaker\Documents (the directory that the file is in), so %F\.. is the directory that file %F is in.  And then %F\..\.. is the parent of that directory.

More notes:

  • Use with care.  If you have any files in C:\pictures, this will try to move them to C:\. If you have any files in C:\pictures\all photos 2013, this will try to move them to C:\pictures, etc.
  • If you want to put this into a script, replace all occurrences of %F with %%F.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .