Fancy Filename Footwork

Ever wanted to take a list of files and turn it into a list of folders? Maybe even with said file inside the newly created folder?

Probably not, but in case you ever have, read on….

I recently had a slew of paper files scanned and wanted to archive them on a shared network drive on our Windows server. The scans we received were PDF files and named according to the company name that appeared on the paper folder’s tab. ABC.pdf, BMF.pdf, CNN.pdf, XYZ.pdf and so on. Wonderful stuff— indexed, OCR’d and fully searchable.

Shift + Right-ClickBut what if you need to add new stuff?

Instead of just plopping the PDFs on the server we decided that each company should have their own folder. Then any new paperwork could be scanned and added to their folder. The first file we would place in each folder would be the recently scanned archive files. Simple enough.

But wait! The idea of manually creating 1500 new folders on our Windows server did not excite me. Then I found a simple script that works from a command prompt. If you shift+right-click the folder in question you can choose “Open a Command Window Here” and execute this command:

for %i in (*) do md "%~ni" && move "%~i" "%~ni"

In a minute you’ll have a list of folders with names that correspond to the files, and each file will be in its respective folder!

Use at your own risk, your mileage may vary, not responsible for any problems resulting from use of these handy tips.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.