-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbulk_file_renamer.bat
127 lines (107 loc) · 2.8 KB
/
bulk_file_renamer.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
@echo off
title Bilk File Renamer
setlocal enabledelayedexpansion
:start
cls
color f
echo Hi there, welcome to Bulk File Renamer
echo by Github: @curlynoemi
echo.
echo ---------------------------------------------------------
echo.
echo What can I help you with? (type the corresponding number)
echo.
echo [1] - Add a portion
echo [2] - Rename a portion
echo [3] - Rename entirely
echo.
echo ---------------------------------------------------------
echo.
echo The folder MUST include only the files you want to Edit.
echo Else you might edit unwanted files.
echo.
set /p "menu= "
if "%menu%"=="1" (
goto addPortion
) else if "%menu%"=="2" (
goto renamePortion
) else if "%menu%"=="3" (
goto renameEntirely
)
rem ---------- ADD A PORTION OF THE FILE NAME ----------
:addPortion
cls
color f
set /p "folderPath=Enter the folder path: "
set /p "textToAdd=Enter what you want to add: "
echo Where do you want to put the text?
echo [b] At the Beginning
echo [e] At the End
set /p "addWhere= "
set /p "partProceed=Can I proceed? (y/n): "
if /i "%partProceed%"=="y" (
for %%F in ("%folderPath%\*") do (
set "fileName=%%~nF"
set "fileExt=%%~xF"
rem Edit the BEGINNING
if /i "%addWhere%"=="b" (
set "newFileName=!textToAdd!!fileName!!fileExt!"
ren "%%F" "!newFileName!"
rem Edit the END
) else if /i "%addWhere%"=="e" (
set "newFileName=!fileName!!textToAdd!!fileExt!"
ren "%%F" "!newFileName!"
)
)
call:success
) else (goto error)
rem ---------- REPLACE PART OF THE FILE NAME ----------
:renamePortion
cls
color f
set /p "folderPath=Enter the folder path: "
set /p "textToRemove=Enter the text you want to replace: "
echo Enter the replacement
set /p "textToAdd=(live blank if you only want to remove): "
set /p "allProceed=Can I proceed? (y/n): "
if /i "%allProceed%"=="y" (
for %%F in ("%folderPath%\*") do (
set "fileName=%%~nF"
set "fileExt=%%~xF"
set "newFileName=!fileName:%textToRemove%=%textToAdd%!!fileExt!"
ren "%%F" "!newFileName!"
)
call:success
) else (goto error)
rem ---------- REPLACE ALL OF THE FILE NAME ----------
:renameEntirely
cls
color f
set /p "folderPath=Enter the folder path: "
set /p "textToAdd=Enter how you want to call the files: "
set /p "allProceed=Can I proceed? (y/n): "
if /i "%allProceed%"=="y" (
set "counter=1"
for %%F in ("%folderPath%\*") do (
set "fileName=%%~nF"
set "fileExt=%%~xF"
set "newFileName=!textToAdd!!counter!!fileExt!"
ren "%%F" "!newFileName!"
set /a "counter+=1"
)
call:success
) else (goto error)
rem ---------- OTHER ----------
:success
cls
echo.
color 2
echo All done!
timeout /t 10 >nul
exit
:error
cls
color 4
echo Ops. Something went wrong, try again.
pause >nul
goto start