Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Help Needed with Searching File/Folder/Move .Bat file

29 Apr 2012   #1

Windows 7 Ultimate x64
Help Needed with Searching File/Folder/Move .Bat file

I've been searching the last 2 hours on a solution to my problem & have yet to find an answer so I thought I would post it here.

Description of Problem:

I have a folder dedicated for songs (guitar tabs & chords) that are .htm extensions, however I would like to move these songs to the/an appropriate Artist folder.

For Example: (current DIR layout)
Folder \ songtitlewithnospaces.htm

Ideal DIR layout
Artist Folder \ songtitlewithnospaces.htm

I have a listing or can create a listing (.txt file) of the songs by the artist, I need a way to search this .txt file for the song name (with no spaces i.e. songwithnospaces.htm) and move the file to the corresponding artist folder.

I would like to create a .bat file for this as I have 1000+ songs and to search/find & move each song file to the correct artist folder would take more time than I have.

Any help would be appreciated, thanks.

My System SpecsSystem Spec
29 Apr 2012   #2

Winbdows 7 ultimate x64 | Ubuntu 12.04 x64 LTS

Can't say about the batch file but have you looked at MediaMonkey Free Media Jukebox, Music Manager, CD Ripper & Converter ?
An excellent app to manage messed up media collection.
My System SpecsSystem Spec
29 Apr 2012   #3

Windows 7 Ultimate x64

It's not my media collection that is messed up, well it is somewhat but I've used media monkey in the past and it's ended up making things worse.

No this is a collection of song chords & tabs (to teach you how to play the song on guitar) and all the files are in .htm or .html format.
My System SpecsSystem Spec

29 Apr 2012   #4

Windows 7 Ultimate x64

Could you upload a text file in the format of,

Artist Name 1

Artist Name 2


Then I could easily create a batch file like,

xcopy /qv songwithnospaces1.htm .\"Artist Name 1"
xcopy /qv songwithnospaces2.htm .\"Artist Name 1"
xcopy /qv songwithnospaces3.htm .\"Artist Name 2"
xcopy /qv songwithnospaces4.htm .\"Artist Name 2"

If that looks right to you.
My System SpecsSystem Spec
29 Apr 2012   #5

Windows 7 Ultimate x64

Currently still searching for an answer but yes attached are two artist documents with their songs.

The format of the .txt files isn't exactly like you want as I think I'm on to something along the lines of what I need.

Using 2 files (Alabama.txt) with Filelist.txt (Dir /b > filelist.txt, from .bat file)

Current .bat file:
:: Get Files In The Directory & Output Them Into Filelist.txt
Dir /b > filelist.txt 
Dir /b|find "string" (C:\Artist\Alabama.txt)
for %%a in (E:\0BACKUP ONLY\DOCS\song lyrics) do move (C:\Artist\)
there are no spaces in the file name of the html files is why the songs are they way they are.

Attached Files
File Type: txt filelist.txt (242.7 KB, 26 views)
File Type: txt Alabama.txt (563 Bytes, 14 views)
File Type: txt BillAnderson.txt (748 Bytes, 9 views)
My System SpecsSystem Spec
29 Apr 2012   #6

Windows 7 Ultimate x64

No attachments, did you click upload after browsing and selecting the files?
Edit: Files there now

Does each Artist have their own text file with a list of their files?
My System SpecsSystem Spec
29 Apr 2012   #7

Windows 7 Ultimate x64

no I'm having to manually create that list & ill be creating the list all the same way
My System SpecsSystem Spec
29 Apr 2012   #8

Windows 7 Ultimate x64

filelist.txt is no good there's no way to determine which file belongs to which artist, except some that have the artist in the title.
The other two I can work with or creating a list in one file in the format I specified before.
My System SpecsSystem Spec
29 Apr 2012   #9

Windows 7 Ultimate x64

that's why I was using 2 files i.e. Alabama.txt to get the songs by them and searching the Filelist.txt for the songs and then moving the .html files to the corresponding artist directory. Just trying to automate the process as much as I can as I have to make each artist song list manually.

I figure that I'll have to end up making a .bat file for each artist which is fine but I'm unfamiliar with all of the .bat file functions.
My System SpecsSystem Spec
29 Apr 2012   #10

Windows 7 Ultimate x64

Make a backup of the files if you havn't already. Now this isn't perfect but if you can create a list for each artist then this should work
@echo off

rem Copy Files
for /F "usebackq delims==" %%i in ("D:\Artist\Alabama.txt") do xcopy /qv "%%ilyricschords.*" ".\Alabama\*.*"
for /F "usebackq delims==" %%i in ("D:\Artist\BillAnderson.txt") do xcopy /qv "%%ilyricschords.*" ".\BillAnderson\*.*"

rem Move Files - requires destination folder to already exist
md Alabama
md BillAnderson
for /F "usebackq delims==" %%i in ("D:\Artist\Alabama.txt") do move "%~dp0%%ilyricschords.html" "%~dp0Alabama\"
for /F "usebackq delims==" %%i in ("D:\Artist\BillAnderson.txt") do move "%~dp0%%ilyricschords.html" "%~dp0BillAnderson\"

Just put it in the same folder as the files.

Only use the 2 copy lines or 2 move lines not all 4. I would use the copy lines as there will be less scripting then if all is successful then you can delete the originals.

Take note the two text files did not contain the extension .html on the file names if any list does then remove .* from "%%ilyricschords.*" for the copy lines or remove .html "%~dp0%%ilyricschords.html" for the move lines.

I can't see anyway of doing this any easier than manually creating the list files. Using a single list file in the format I specified before would take just as long to create but using find and replace in a good text editor could speed up the batch file creation.

EDIT: Just looked at your filelist.txt again and noticed all files contain "lyricschords" on the end so I updated the code to work with that.

EDIT: New and improved code in next post.
My System SpecsSystem Spec

 Help Needed with Searching File/Folder/Move .Bat file

Thread Tools

Similar help and support threads
Thread Forum
Can move only one file at a time within same folder or get error msg
I often need to reorganise files and sub-folders within the same main folder, for example, move folder from sub-folder named documents to sub-folder named photos. However Explorer in Windows 7 Professional will only allow me to move one folder at a time. When I try to move a second folder I get the...
General Discussion
Can't rename, delete or move folder or file
Since 2 days, in a certain folder, I cant rename, move or delete folders or files. Now, it has spread to my desktop as well. If I rename a folder, even a new folder, the name changes ''magically'' within seconds to restore to its previous name. If I move the folder or file, it comes back and if I...
BSOD Help and Support
How do I move the Libraries folder location in File Explorer?
The default build on my work machine is really annoying me. They moved around default locations of several system-type folders. Specifically, the Libraries folder in File Explorer is not on it's own root. it is instead, under the "Desktop" folder. I want to return the Libraries folder to...
General Discussion
how to move file in folder
before you reinstall w7 files in folders can be moved example files beginning with the letter A, which is the top of the folder can be moved at the bottom closing and opening the folder remains the all clear but now sit as "glued" from where they waved box to be able to move
BSOD while 'Move File to Folder' option
hi guys. approximately 10 minutes ago, i was moving a 1.1GB mkv file from one of my partitions to a harddrive connected to my computer via the USB port. my system ; win 7 ultimate 32bit intel q9550 gigabyte EP43-UD3L 2x2GB corsair dominators ddr2 1066mhz all stock, no raids, no...
BSOD Help and Support

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 11:02.
Twitter Facebook Google+