Move contents of folders of a certain name to their parent

Javascript renaming examples. Javascript renaming is supported in version 3 or newer.

Move contents of folders of a certain name to their parent

Postby neurocrash » Wed Apr 21, 2021 3:24 am

Hi,

I have a directory structure like this with several thousand folders, and wish to move all files out of folders named CUE into their parent folders. Is there any way to do it?

Thanks very much for looking.

Code: Select all
Folder 1
--------CUE
---------------------File 1
---------------------File 2
Folder 2
--------Subfolder 1
---------------------CUE
--------------------------------File 1
--------------------------------File 2
--------Subfolder 2
---------------------CUE
--------------------------------File 1
--------------------------------File 2
neurocrash
 
Posts: 5
Joined: Wed Apr 21, 2021 3:01 am

Re: Move contents of folders of a certain name to their parent

Postby Admin » Wed Apr 21, 2021 10:12 am

Try this Javascript:

Code: Select all
newPath = object("folder");
newPath.replace("CUE\\", "");
newLocation = newPath;


In Copy/Move to Location (13) enter .\ (just a dummy folder because the location will be overwritten by Javascript)
Deselect the option "Copy Not Move" check box.

Select all the files you want to move and preview. Then rename.
Try on a few test files first.
Admin
Site Admin
 
Posts: 2041
Joined: Tue Mar 08, 2005 8:39 pm

Re: Move contents of folders of a certain name to their parent

Postby Admin » Fri Apr 23, 2021 1:53 am

There is also a way to do the same without Javascript:

- In the BRU menu -> Renaming Options -> Advanced options, enable "Renaming Options, Advanced Options, Allow using '\' in Renaming Criteria".
- In Add(7) set "Prefix" to ..\ to move all files up
- With Filters (12) select all the files that are in a folder CUE.

Raname.
Admin
Site Admin
 
Posts: 2041
Joined: Tue Mar 08, 2005 8:39 pm


Return to Javascript Renaming