Page 1 of 1

Append prefix only for files within specific folder name

PostPosted: Fri Dec 22, 2017 4:03 pm
by jyip
Looking to setup a scheduled task to append a prefix "Arch" to files that only reside in folders named "Archive" and ignore the rest using Bulk Rename Command.

A bonus would be if it already has the "Arch" prefix, to leave it as is.

Re: Append prefix only for files within specific folder name

PostPosted: Wed Mar 27, 2019 6:42 pm
by bru
The below batch works, but note your folder-name match is case-insensitive.
It works recursively, but only in folders named archive, Archive, etc.
Files already beginning as Arch* will be left alone.

@echo off
For /f "delims=" %%A in ('dir/b/s/ad Archive*') DO @If /i "%%~nA"=="Archive" (
brc32 /Dir:"%%A" /NoFolders /Prefix:Arch /Regexp:"^(Arch)+(.*):Arch\2" /execute)
echo.
echo.
echo.Done, press any key to exit.
pause>nul

Re: Append prefix only for files within specific folder name

PostPosted: Fri May 22, 2020 3:10 pm
by groundswell
Thanks for the reply and help!

I ran the example you gave me and it ran without error but didnt seem to rename any of the files. Here's what I ran and screenshots below of results. I figured I will test manually first before creating a batch file.
C:\BRC\BRC64.exe /removename /appendfolder:P::1 /pattern:*.TXT /recursive

Image

Image