简体   繁体   中英

How to Add prefix to all file in current folder and subfolder using batch file

I am trying to add prefix to all files in current folder and it's subfolders and i made the following batch file

setlocal enabledelayedexpansion
for %%j in (*) do (
set filename=%%j
rename !filename! [nilesh.uk.to]-!filename!
)

it working for current directory only but i want to add prefix to all files in current folder as well as subdirectory please help me to solve this problem

Run this from another folder, and the pushd is used otherwise the batch file will be renamed too. Change c:\\mainfolder to your main folder name

@echo off
pushd "c:\mainfolder\"
for /r %%j in (*) do (
   rename "%%j" "[nilesh.uk.to]-%%~nxj"
)
popd

使用重命名器 ,您可以通过以下命令执行此操作:

$ renamer --regex --find '^' --replace 'prefix-' '**'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM