Reputation: 11
I'm not great at coding in any way. I figured out that I would need to start using some code to make some tasks a lot less tiresome.
I'm currently using Plex TV which is a media server that allows you to upload TV series and movies to the online server and you can then beam it directly to a TV from a phone app. (How awesome right!)
I'm trying to upload the files, but it needs to match a certain path for it to work properly.
E.g.: TV Shows\Greys Anatomy\Season 1\Greys Anatomy - S01E01\
I've got 9 seasons worth of Greys Anatomy, but the file names are missing the hyphen: Grey's Anatomy S01E0
Is there a way to rename MULTIPLE files and insert -
between Anatomy
and S01E01
.
I have 9 seasons without the hyphen.
I've looked at a command such as ren "Greys Anatomy "* "Greys Anatomy - "*
, but it isn't working. It replaces the following S
and then it screws it all up. I'm sure there is an easy solution, but I'm not good at coding and have been trying for an hour or two now.
Upvotes: 1
Views: 949
Reputation: 49086
The command syntax is: Command name ren
, SPACE, argument string for file(s)/folder(s) to rename optionally with path enclosed in double quotes, SPACE, argument string for new file/folder name(s) enclosed in double quotes always without path.
So the correct command line to use would be with wildcard *
inside the double quoted first and second argument strings:
ren "Grey's Anatomy *" "Greys Anatomy - *"
But this command line does not work as you want it. The number of characters in current file name up to *
are 15 while the number of characters in new file name up to *
are just 14. For that reason command REN takes also the next character S
and renames Grey's Anatomy S01E01
with this command line to Greys Anatomy - 01E01
with S
missing.
I suggest to use a batch file with following code on which the second line must be adapted by you as you have not posted full qualified path of the files to modify:
@echo off
set "SourceFolder=C:\Temp\TV Shows\Greys Anatomy"
for /F "delims=" %%I in ('dir "%SourceFolder%\Grey*Anatomy*" /A-D-H /B /S 2^>nul') do (
for /F "eol=| tokens=2*" %%A in ("%%~nxI") do ECHO ren "%%I" "Greys Anatomy - %%B"
)
set "SourceFolder="
pause
Note: There is ECHO
left to command ren
in fourth line to just output the rename command instead of really doing the rename. Run this batch file and verify if the output rename command lines would produce what you expect. On a positive result remove ECHO
, save the batch file and run it once again to really rename the files.
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
dir /?
echo /?
for /?
pause /?
ren /?
set /?
By the way: There are GUI applications like shareware file manager Total Commander which make it possible to do such file rename operations also for people with no experience in writing code using just the computer mouse.
Upvotes: 1