I have my test file in c:\0 so I change SET @SOURCE=C:\0 Folder named AL1030004_502010109H_20151102_163916
But nothing changes ----------------------------- Bambi Saastad office 952-402-7888 cell 612-963-1478 On Wed, Nov 4, 2015 at 10:38 AM, Andrew S. Baker <[email protected]> wrote: > Thanks. > > It would have been nice if I had not butchered my commentary as well, due > to an untimely "not" > > :) > > > > > > > *ASB **http://XeeMe.com/AndrewBaker* > <https://urldefense.proofpoint.com/v2/url?u=http-3A__xeeme.com_AndrewBaker&d=CwMFaQ&c=IGDlg0lD0b-nebmJJ0Kp8A&r=obHQuFiv8wJZBUNiImMvWQrl0l4A41oCvtlhst1h3FI&m=tNysc0nNJZTWzm1i83ob3z7t80rDYdW4uw04omdVZQI&s=SpzDT8UzZN4WGRg7Yq1nNvI1F1IENuUCDjn6Il5HqSM&e=> > *Providing Virtual CIO Services (IT Operations & Information Security) for > the SMB market…* > > * GPG: *1AF3 EEC3 7C3C E88E B0EF 4319 8F28 A483 A182 EF3A > > > On Wed, Nov 4, 2015 at 11:17 AM, James Rankin <[email protected]> wrote: > >> Nice J >> >> >> >> *From:* [email protected] [mailto: >> [email protected]] *On Behalf Of *Andrew S. Baker >> *Sent:* 04 November 2015 16:11 >> *To:* ntsysadm <[email protected]> >> *Subject:* Re: [NTSysADM] Rename Directories >> >> >> >> I already have a script that does this ( >> http://KB.UltraTech-llc.com/Scripts/?File=BulkRename.BAT >> <https://urldefense.proofpoint.com/v2/url?u=http-3A__KB.UltraTech-2Dllc.com_Scripts_-3FFile-3DBulkRename.BAT&d=CwMFaQ&c=IGDlg0lD0b-nebmJJ0Kp8A&r=obHQuFiv8wJZBUNiImMvWQrl0l4A41oCvtlhst1h3FI&m=tNysc0nNJZTWzm1i83ob3z7t80rDYdW4uw04omdVZQI&s=JE7W8_e2MVugPV3ivvUjZNNKoQqam49kRtabmUihXLQ&e=>) >> but the way to solve your specific problem is not to actually deal with >> each filename as a single token, rather than multiple tokens. >> >> >> >> Assuming the folders in question are all in one directory, consider the >> following: >> >> >> >> *SETLOCAL ENABLEDELAYEDEXPANSION* >> >> *SET @SOURCE=C:\SomeFolder* >> >> *FOR /D %%V IN (%@SOURCE%\*) DO (* >> >> * SET @OLDNAME=%%~V* >> >> * SET @NEWNAME=!@OLDNAME:502010109H=OutProcessedABS!* >> >> * SET @RENAME=!@NEWNAME:%@SOURCE%\=!* >> >> * IF NOT /I "!@OLDNAME!"=="!@NEWNAME!" (* >> >> * ECHO Renaming "!@OLDNAME!" to "!@RENAME!"* >> >> * RENAME "!@OLDNAME!" "!@RENAME!"* >> >> * )* >> >> *)* >> >> >> >> >> >> Doing it the way it is above, you won't need to worry about how many >> segments each folder has. You'll only change the name from X to Y if it >> has X segment in the name. >> >> >> >> You can modify the FOR loop if you have the folders more spread out than >> that (perhaps using /R or a lovely /F). >> >> >> >> Regards, >> >> >> >> >> >> >> >> >> >> *ASB **http://XeeMe.com/AndrewBaker* >> <https://urldefense.proofpoint.com/v2/url?u=http-3A__xeeme.com_AndrewBaker&d=CwMFaQ&c=IGDlg0lD0b-nebmJJ0Kp8A&r=obHQuFiv8wJZBUNiImMvWQrl0l4A41oCvtlhst1h3FI&m=tNysc0nNJZTWzm1i83ob3z7t80rDYdW4uw04omdVZQI&s=SpzDT8UzZN4WGRg7Yq1nNvI1F1IENuUCDjn6Il5HqSM&e=> >> *Providing Virtual CIO Services (IT Operations & Information Security) >> for the SMB market…* >> >> * GPG: *1AF3 EEC3 7C3C E88E B0EF 4319 8F28 A483 A182 EF3A >> >> >> >> On Wed, Nov 4, 2015 at 5:32 AM, Bambi J Saastad < >> [email protected]> wrote: >> >> Hoping for some help with renaming directories >> >> I had hoped to just use the move command but I get syntax errors.... >> >> The directories are named in this manner >> >> AL1030004_502010109H_20151102_163916 >> >> I need to replace the middle 502010109H with OutProcessedABS >> >> >> >> so it would become >> >> AL1030004_OutProcessedABS_20151102_163916 >> >> >> >> I think I need to instead use a for loop, but I cannot get that syntax >> right either >> >> Any quick suggestions? >> >> >> >> Thx >> >> B? >> >> >> >> ----------------------------- >> Bambi Saastad >> office 952-402-7888 >> cell 612-963-1478 >> >> >> > >
