Delete a subfolder keeping files in mainfolder

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Delete a subfolder keeping files in mainfolder

Postby sanderik » Fri Apr 04, 2014 6:41 am

Hi, Is it possible with Bulk Rename to remove files from a subfolder to the main folder. The main folder is 1 level higher.
I will do this in one time with a selection in more than 1 subfolder at a time.
I think that the "New Location (13) could be a possibility with a correct command line?!
I tried with a [dot] but files were gone. (Of course I had a copy :wink: )
Thanks for your answer.
Erik Vercruysse
training partner of the Digital Academy Belgium
sanderik
 
Posts: 2
Joined: Fri Apr 04, 2014 6:25 am

Move files to ParDir, then delete SubDir

Postby truth » Tue Apr 08, 2014 1:54 am

As a renamer, BRU provides no delete command,
& its only move/copy-command points to a static folder spec'd by 13Path.

Deletions(overwrites) only occur if using BRU's move/rename-to a pre-existing-name,
(and only if a user has pre-checked: Options/OverwriteTargetFiles).
In which case, Options/PreventDuplicates can suffix NewNames to prevent overwrites.

A lone . or .. represents BRU's CurWorkingDir (set when BRU was launched).
The folder spec'd in 13Path remains static, & never changes per 'file-being-processed'.

You would need to be careful selecting filenames, when working with SubDirs at varying depth-levels,
since all selected files would be moved into that same directory.

Many users requested more functional move/copy/delete/compare commands to be incorporated,
but the furthest it ever got, was a static-folder in 13Path for move/copy commands.
I think ViceVersa was meant to cater towards that crowd.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: Delete a subfolder keeping files in mainfolder

Postby sanderik » Fri Apr 25, 2014 10:08 am

Thanks for your reply.
I give a good example for the reason of my Question.
A lot of Vector files we buy are in a zip-file. By unpacking them the files are in a specific folder.
For example the main folder is Beautiful shopping objects.
In that folder a collection of 50 different files are zipped. Because of the same name "content", 1 EPS and 1 JPG file I need tounpack creating a subfolder.
BRU offer a great solution to rename the files to the foldername. Once this is done, and there are a huge number of other folders too I will replace the files into one folder together and the main folder is the place i will have them.
Thats why I was thinking te replace files to the mainfolder depending the levels to change (replace them). Deleting the empty subfolder is not nescessary because ther are other possibilities to delete empty folders at once.
sanderik
 
Posts: 2
Joined: Fri Apr 04, 2014 6:25 am

Move files to ParDir, then delete SubDir

Postby truth » Sat Apr 26, 2014 12:00 pm

Im afraid I mis-understand the scenario.
There should be no reason to SubDir-separate SameName.eps from SameName.jpg?
Unless perhaps using an app that disregards file-extensions (or has other special requirements)?

If so, I'd unpack into 1Folder & then BRU-rename as: Same.Name.eps -> Same.Name-eps.eps
1Regex settings:
(.*)(\..*)
\1-\2
IncludeExt=Checked

That would eliminate the need to: CreateSubDir / RenameBySubDir / MoveUp1Dir
Throw in 12Filters like *.jpg *.eps to only affect those filetypes if needed.
Just edit the replace if you have a name-format that must be adhered to.


-----------------------------------------------------------------------------------------------------------------
If you meant that EPS/JPG are SubDirNames within .zip? I'd unpack to those default folders,
then rename similiarly, but only to ensure unique filenames before moving them up 1-directory.

Here's some example batch-lines that could prove helpful, depending on your scenario:
FOR /f "delims=" %%d IN ('dir /ad/b') DO for /f "delims=" %%f in ('dir /b/a-d "%%d\*.*"') do IF not exist "C:\DirPath\ParentDir\%%f" move "%%d\%%f" .
FOR /f "delims=" %%b in ('dir /b/ad') do brc32 /Dir:"C:\DirPath\ParentDir\%%b" /nofolders /ignorefilex /regexp:(.*)\.(.*):\1-\2.\2 /execute
FOR /f "delims=" %%d IN ('dir /ad/b') DO for /f "delims=" %%f in ('dir /b/a-d "%%d\*.*"') do IF not exist "C:\DirPath\ParentDir\%%f" move "%%d\%%f" .
FOR /f "delims=" %%k in ('dir /b/ad/s') do RD "%%k"


Line1 moves all files 1-SubDir below ParentDir into ParentDir (unless pre-existing names already exist there)
Line2 renames left-behind-files that couldnt be moved (as: filename-ext.ext)
Line3 moves those renamed files into ParentDir
Line4 then deletes all empty directories

While C:\DirPath\ParentDir\ is hard-coded into 3 batchlines, it's obviously not preferrable.
Omitting it (leaving all "" intact) lets you to run the batch against any ParentDir by typing:
BatchName.bat "C:\DirPath\YourParentDir" from the prompt, etc.

I included DirPaths as a precaution, since anyone could copy/paste this into a batch, & then just click it!
It'd be deadly without DirPaths (unless placed in the right ParDir & they were happy with the rename-structure)
I have a similiar batch that 1st displays CurDir & intentions, then prompts for user-input before executing.

I usually let sed create such commands, but it dawned on me that a nested FOR statement might work.
I know we're not supposed to, but it worked fine on my system, your mileage may vary, might be worth testing.
Just throwing out different ideas/approaches, since BRU doesnt offer selective SubDir depth-levels.
Hopefully some of this will prove helpful, though I misunderstand the DirStructure/names within .zips
Good luck, & post back if you wish to pursue any further.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay


Return to BRU Support