How to rename 80.000 files at once in Windows
Solution 1:
You can use the built in rename
or ren
command:
ren *.jpg ._*.jpg
Though, as with all these things, try it on a directory containing just a few files first.
Solution 2:
Here's a way using PowerShell:
Navigate to your folder and run this command
Get-ChildItem *.jpg | Rename-Item -newname {"._" + $_.Name}
Extra bonus short version:
gci *.jpg | ren -newname {"._" + $_.Name}
Solution 3:
I have 2 solutions:
-
All files are in the same folder
-
run the following from command prompt on that folder:
for /f "delims=¯" %i in ('dir /b /on') do ren "%i" "._%i"
-
-
complete solution when there are files in subfolders AND when you wanna to replace the "n" first characters with a string you want :D
- create a batch file with the following command
- change variable parameters to what you want
-
path
: put inside""
the root path of your files (e.g. "C:\documents and settings\user\desktop\new folder" -
numfirstchars2replace
: put a number with the first characters to replace (in your case, 2) -
str2put
: put a string to be added as a prefix of the new filename (in your case,._
)
-
- run it in a folder different from where the files are
@echo off
::only to tell user what this bat are doing
echo.1.initializing...
::enable that thing to allow, for example, incremental counter in a for loop :)
echo.- EnableDelayedExpansion
SETLOCAL EnableDelayedExpansion
::variables
echo.- variables
:: - place here the absolute root path of your files
set path="put here where are the root folder of your files"
set pathbak=%cd%
set numfirstchars2replace=2
set str2put=._
::go to %path% and its driveletter
echo.- entering the path you want
for /f "delims=¯" %%i in ('echo.%path%') do %%~di
cd %path%
::search all subfolders and save them to a temp file
echo.- searching for subfolders
echo.%path%>%temp%\tmpvar.txt
for /f "delims=¯" %%i in ('dir /s /b /on /ad') do echo."%%i">>%temp%\tmpvar.txt
::execute command for root folder and all found subfolders
echo.
echo.2.executing...
for /f "delims=¯" %%i in (%temp%\tmpvar.txt) do (
cd %%i
echo.- in folder: %%i
for /f "delims=¯" %%j in ('dir /b /on /a-d') do (
set newname=%%j
set newname=!newname:~%numfirstchars2replace%,1000!
echo.- renaming from "%%j" to "%str2put%!newname!"...
ren "%%j" "%str2put%!newname!"
)
)
echo.
echo.3.exiting...
::return to %pathbak% and its driveletter
for /f "delims=¯" %%i in ('echo.%pathbak%') do %%~di
cd %pathbak%
@echo on
Solution 4:
If they are all in the same folder, you could select them all with Control
+ A
and then hit F2
to rename one of them. All subsequent files will be named file(2), file(3), etc
Solution 5:
Try Powershell (preinstalled in Windows 7):
Get-Childitem /path/to/your/files | foreach-object { move-item $_ $("._" + $_.name) }
(tested it in my download-dir.)
Edit: Siim K's code will append an additional ".jpg" to every "._filename.jpg". Remove that last ".jpg" in Siim K's code and you have a short, elegant code to rename your files.