Copy text from a website, then rename files with it
Moderator: DosItHelp
Copy text from a website, then rename files with it
Howdy all
I have folder after folder of TV seasons, all files have horribly ugly names. I have used a file renmaing program to rename them in a tidy uniform format, eg "The Simpsons (S05E03) - ".
Now what I usually do is open Wikipedia, go to the shows List Of Episodes page, copy each episode name and paste it to the end of each file name. Very time consuming.
I would like run a batch file that copies each episode name I guess into a new line in a text file, then use the text file to extract the names then append to each filename. I suppose I would have to manually open the web page and scroll so the information started a specific number of lines from the top of the browser (the same each time), the get string at the coordinates containing each episode name? To start..
I have folder after folder of TV seasons, all files have horribly ugly names. I have used a file renmaing program to rename them in a tidy uniform format, eg "The Simpsons (S05E03) - ".
Now what I usually do is open Wikipedia, go to the shows List Of Episodes page, copy each episode name and paste it to the end of each file name. Very time consuming.
I would like run a batch file that copies each episode name I guess into a new line in a text file, then use the text file to extract the names then append to each filename. I suppose I would have to manually open the web page and scroll so the information started a specific number of lines from the top of the browser (the same each time), the get string at the coordinates containing each episode name? To start..
Re: Copy text from a website, then rename files with it
Some examples of what all your data looks like and how we are suppose to match them to append the new file name would really help.
Re: Copy text from a website, then rename files with it
Multi-posted.
nathan323, posting your question here, there, and maybe at 5 other sites means that many people are going to waste their time replying.
nathan323, posting your question here, there, and maybe at 5 other sites means that many people are going to waste their time replying.
Re: Copy text from a website, then rename files with it
I'm intending to post any answers as I get them to the places I have posted the question, so I guess it can only benefit anyone who comes across these posts..
ok thanks for the replies.
Here are my list files:
The Walking Dead (S02E01) - .avi
The Walking Dead (S02E02) - .avi
The Walking Dead (S02E03) - .avi
The Walking Dead (S02E04) - .avi
The Walking Dead (S02E05) - .avi
The Walking Dead (S02E06) - .avi
The Walking Dead (S02E07) - .avi
The Walking Dead (S02E08) - .avi
The Walking Dead (S02E09) - .avi
The Walking Dead (S02E10) - .avi
The Walking Dead (S02E11) - .mp4
The Walking Dead (S02E12) - .mp4
I then want to append each file name with its corresponding episode name. These names are listed in a text file, each on a new line, in the same ascending order as the episodes:
What Lies Ahead
Bloodletting
Save the Last One
Cherokee Rose
Chupacabra
Secrets
Pretty Much Dead Already
Nebraska
Triggerfinger
18 Miles Out
Judge, Jury, Executioner
Better Angels
Beside the Dying Fire
ok thanks for the replies.
Here are my list files:
The Walking Dead (S02E01) - .avi
The Walking Dead (S02E02) - .avi
The Walking Dead (S02E03) - .avi
The Walking Dead (S02E04) - .avi
The Walking Dead (S02E05) - .avi
The Walking Dead (S02E06) - .avi
The Walking Dead (S02E07) - .avi
The Walking Dead (S02E08) - .avi
The Walking Dead (S02E09) - .avi
The Walking Dead (S02E10) - .avi
The Walking Dead (S02E11) - .mp4
The Walking Dead (S02E12) - .mp4
I then want to append each file name with its corresponding episode name. These names are listed in a text file, each on a new line, in the same ascending order as the episodes:
What Lies Ahead
Bloodletting
Save the Last One
Cherokee Rose
Chupacabra
Secrets
Pretty Much Dead Already
Nebraska
Triggerfinger
18 Miles Out
Judge, Jury, Executioner
Better Angels
Beside the Dying Fire
Re: Copy text from a website, then rename files with it
Can you guarantee that the Episode names are in the correct order? If not we can't guarantee the accuracy of the Episode Name appending.
What do you want the output file name to look like?
What do you want the output file name to look like?
Re: Copy text from a website, then rename files with it
Yes. I just copied them from Wikipedia using the method I described.
I want them to look like what I showed above, eg.
The Walking Dead (S02E01) - What Lies Ahead.avi
I'll be doing this many times in the future, so I wanted to know what the correct syntax was for the batch file.
I want them to look like what I showed above, eg.
The Walking Dead (S02E01) - What Lies Ahead.avi
I'll be doing this many times in the future, so I wanted to know what the correct syntax was for the batch file.
Re: Copy text from a website, then rename files with it
Easy enough to do but I am short on time right now.
Basically what will happen is you will use a FOR command to iterate all your AVI files and then you will stream in the list of file names you want to append to the end of each file.
Basically what will happen is you will use a FOR command to iterate all your AVI files and then you will stream in the list of file names you want to append to the end of each file.
Re: Copy text from a website, then rename files with it
It's a bit more complex than I suggested.
This expects that in the current folder are
A) the files which need text added to the end of the filename
B) plus file1.tmp which contains the text to be appended to each filename - in the correct order as the filenames files are sorted.
C) this batch file
Be aware the the order of the filenames in an explorer window is not always the same as in a cmd prompt.
Perform a dir /b /a-d /p command in the folder to double check the order.
It performs a brief DIR command into a file and then interleaves the info from the two files,
and writes undo.bat so you can reverse the rename in case something went wrong - the undo.bat file will be deleted/changed if you run it twice so be careful.
This expects that in the current folder are
A) the files which need text added to the end of the filename
B) plus file1.tmp which contains the text to be appended to each filename - in the correct order as the filenames files are sorted.
C) this batch file
Be aware the the order of the filenames in an explorer window is not always the same as in a cmd prompt.
Perform a dir /b /a-d /p command in the folder to double check the order.
It performs a brief DIR command into a file and then interleaves the info from the two files,
and writes undo.bat so you can reverse the rename in case something went wrong - the undo.bat file will be deleted/changed if you run it twice so be careful.
Code: Select all
@echo off
:: creates file2.tmp from DIR and appends the information from file1.tmp onto the filenames
:: designed to rename files and add info onto the end of the filename
setlocal DisableDelayedExpansion
del undo.bat renfile.bat 2>nul
dir /b /a-d |find /v /i "%~nx0" |find /v /i ".tmp" >file2.tmp
< file1.tmp (
for /F "usebackq delims=" %%a in ("file2.tmp") do (
set File2Line=
set /P File2Line=
set "File1Line=%%~na" & set "ext=%%~xa"
setlocal EnableDelayedExpansion
echo(ren "!File1Line!!ext!" "!File1Line!!File2Line!!ext!"
echo(ren "!File1Line!!File2Line!!ext!" "!File1Line!!ext!">>undo.bat
endlocal
)
) >renfiles.bat
call renfiles.bat
del renfiles.bat
del file2.tmp
Re: Copy text from a website, then rename files with it
Dude, that works perfectly Thanks a lot for your help. Im saving the macro'd list from word as VideoRename.txt, so I just changed that in the batch.