Move files to folders with similar names...

Started by CHF-Mark, November 09, 2022, 08:43:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

CHF-Mark

I am running Win 10 and would like to create a .bat file that accomplishes the following:

Checks each filename in a folder and then compares them to folder names in another folder.
If ANY part of the filenames match the folder name, move the file to that folder.

So files would be located in this folder:  d:\data\special\
And the folders to move these files to would be located here:  e:\

So here are some example files:
home garden.txt
Photos home.doc
Name home score.jpg

And here are some folder names to move the files into:
d:\garden
d:\presents
d:\chores
etc.

I'm sure a for loop would be needed to set this up but I don't have the skills
to write the code.

Any help would be appreciated!

I've searched online for this but nothing quite fits the bill.

CHF-Mark

Quote from: CHF-Mark on November 09, 2022, 08:43:48 PM


So here are some example files:
home garden.txt
Photos home.doc
Name home score.jpg

And here are some folder names to move the files into:
d:\garden
d:\presents
d:\chores
etc.


I see I need to adjust my example folders a bit.  :)

And here are some folder names to move the files into:
d:\garden
d:\home
d:\presents
d:\chores
etc.

I hope it's clearer now.