Moving all elements from selected folders into parent folder

English support forum

Moderators: sheep, Hacker, Stefan2, white

Post Reply
leo007
Junior Member
Junior Member
Posts: 29
Joined: 2019-10-28, 08:09 UTC

Moving all elements from selected folders into parent folder

Post by *leo007 » 2019-11-03, 18:29 UTC

Dear TC Community

I'm looking for a way to move all the elements in the selected folders into the parent folder (without actually entering selected folder)
then delete these empty folders.

if there is a Autohotkey script it would be awesome

From

Code: Select all

D:.
└───Folder A
    │   text 01.txt
    │   text 02.txt
    │
    └───Folder B
        └───Folder C
            │   img 01.jpg
            │   img 02.jpg
            │
            └───Folder D
                    text 03.txt
                    
To

Code: Select all

D:.
└───Folder A
    │   img 01.jpg
    │   img 02.jpg
    │   text 01.txt
    │   text 02.txt
    │
    └───Folder D
            text 03.txt
            

any Help would be Highly appreciated)
Many thanks in advance
Last edited by leo007 on 2019-11-05, 17:23 UTC, edited 2 times in total.

User avatar
obeg
Junior Member
Junior Member
Posts: 36
Joined: 2006-09-28, 09:20 UTC
Location: Sweden

Re: Moving all elements from selected folders into parent folder

Post by *obeg » 2019-11-05, 11:52 UTC

I don't know if this is what you want, but Ctrl+A (or Numpad +) to select all and then F6 (move) and then write .. to move to parent folder.
But it doesn't inklude AHK script

User avatar
Vochomurka
Power Member
Power Member
Posts: 790
Joined: 2005-09-14, 22:19 UTC
Location: Russia
Contact:

Re: Moving all elements from selected folders into parent folder

Post by *Vochomurka » 2019-11-05, 12:21 UTC

Single user license #329241
PowerPro scripts for Total Commander

User avatar
Horst.Epp
Power Member
Power Member
Posts: 3475
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Moving all elements from selected folders into parent folder

Post by *Horst.Epp » 2019-11-05, 12:45 UTC

Multirename allows to move files.
Proceed as follows:

Select you dirs
Search for all files in selected dirs (search for is empty)
Feed to listbox
Ctrl-A to select all files
Open Multirename and enter ..\[N] as new name
Start
Windows 10 Home x64 November 2019 Update, Version 1909 (OS Build 18363.476)
Intel(R) Core(TM) i7-4770 CPU @ 3.40GH, 16GB RAM
TC 9.50ß8 x64 / x86, Everything 1.4.1.959 (x64)

leo007
Junior Member
Junior Member
Posts: 29
Joined: 2019-10-28, 08:09 UTC

Re: Moving all elements from selected folders into parent folder

Post by *leo007 » 2019-11-05, 17:27 UTC

Thanks everyone for suggestions)

User avatar
Hacker
Moderator
Moderator
Posts: 11398
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Moving all elements from selected folders into parent folder

Post by *Hacker » 2019-11-06, 19:26 UTC

leo007,
I am not sure I understand the logic. Folder A is selected to be processed. Files from Folder C (two levels down) are moved to Folder A (two levels higher) but files in Folder D (three levels down) are left untouched?

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.

User avatar
Usher
Power Member
Power Member
Posts: 631
Joined: 2011-03-11, 10:11 UTC

Re: Moving all elements from selected folders into parent folder

Post by *Usher » 2019-11-06, 19:46 UTC

2Hacker
Roman, all the content of folder C (including files and subfolder D) is moved two levels up to folder A, then empty folders are deleted.
Regards from Poland
Andrzej P. Wozniak

User avatar
Hacker
Moderator
Moderator
Posts: 11398
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Moving all elements from selected folders into parent folder

Post by *Hacker » 2019-11-06, 20:01 UTC

Usher,
But, which folder is selected? And why move two levels up if the request is to move to the parent folder (one level up)?

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.

User avatar
Usher
Power Member
Power Member
Posts: 631
Joined: 2011-03-11, 10:11 UTC

Re: Moving all elements from selected folders into parent folder

Post by *Usher » 2019-11-07, 01:57 UTC

2Hacker
The problem isn't properly defined, I think. Suppose you have directory A as parent and by mistake you have started more or less recursive moving of selected files and dirs to more and more nested subdirs, for example to B\B\B\B\B\B\B. Now you want to move those files and dirs back to parent directory A.

In the simplest solution you open directory A in the left panel and navigate in the right panel (Ctrl+Right, Tab, Down, Enter, Down, Enter, Down, Enter, etc.) to the first subdirectory with files inside, then select all files and dirs there and move them (F6) to parent directory A, finally press Tab to go back to directory A and delete subdirectory B.

The problem is: HOW to NOT navigate as described above?
Regards from Poland
Andrzej P. Wozniak

leo007
Junior Member
Junior Member
Posts: 29
Joined: 2019-10-28, 08:09 UTC

Re: Moving all elements from selected folders into parent folder

Post by *leo007 » 2019-11-07, 18:11 UTC

Hacker,Usher Thanks for your active involvement in this Topic.
here is my small script that apply the logic for most part. triggered by Alt + G

Logic is: move all inner content of selected parent folder 1 level up. delete Empty parent folder

Code: Select all

#SingleInstance, force   
#Persistent                  
#NoTrayIcon

	!g:: ; Unpack Folder
	{
		Send, ^c
		sleep, 100
		selectedfolder = %clipboard%
		SplitPath, selectedfolder,, OutDir
		loop,files, %selectedfolder%\*.*, DFR
				{
						FileMoveDir, %A_LoopFileFullPath%, %outdir%, 1
						FileMove, %A_LoopFileFullPath%, %outdir%, 1
				}
		FileRemoveDir ,%selectedfolder%
		return
	}
for every one who don't what to mass with Scripting but just want to use this functionality,
I compiled x64, x32 exe files that get Triggered by clicking UnpackFolder32/64.exe.

Instruction:
1] Extract Archive
2] drag the UnpackFolder32/64 to button bar.
3] as a parameter %P%S

to unpack folder just select the wanted folder and click the button! Done

Download Link:
https://drive.google.com/open?id=1NmkhEUwG2izm7FI2XTg4NsP5B6cfgJsj

User avatar
Hacker
Moderator
Moderator
Posts: 11398
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Moving all elements from selected folders into parent folder

Post by *Hacker » 2019-11-07, 20:08 UTC

leo007,
If I understand your script correctly, it does not do what you described in the examples in your first post, though.
Also, the R in DFR should be unnecessary, DF should be enough.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.

leo007
Junior Member
Junior Member
Posts: 29
Joined: 2019-10-28, 08:09 UTC

Re: Moving all elements from selected folders into parent folder

Post by *leo007 » 2019-11-07, 20:19 UTC

Hacker
for the most part it does but in more simplistic way :)


From:

Code: Select all

D:.
│
└───Folder A
    └───Folder B
        │   text 01.txt
        │   text 02.txt
        │
        └───Folder C
            └───Folder D
                    img 01.jpg
                    img 02.jpg
                    
To

Code: Select all

D:.
└───Folder A
    │   text 01.txt
    │   text 02.txt
    │
    └───Folder C
        └───Folder D
                img 01.jpg
                img 02.jpg
                




Hacker wrote:
2019-11-07, 20:08 UTC
the R in DFR should be unnecessary, DF should be enough.
Thanks for note.

User avatar
Hacker
Moderator
Moderator
Posts: 11398
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Moving all elements from selected folders into parent folder

Post by *Hacker » 2019-11-07, 20:32 UTC

leo007,
in more simplistic way
Yup, that's what I meant.
I still don't understand the logic behind your initial From -> To example.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.

leo007
Junior Member
Junior Member
Posts: 29
Joined: 2019-10-28, 08:09 UTC

Re: Moving all elements from selected folders into parent folder

Post by *leo007 » 2019-11-07, 20:45 UTC

Hacker
Hacker wrote:
2019-11-07, 20:32 UTC
I still don't understand the logic behind your initial From -> To example.
I done assumption that if the inner sub folder contain inside only one folder without any extra files it unpack it automatically and it goes on and on...
but I realized its unnecessary and open door for potential Errors.
hope now its a bit more clear what initial From -> To example ment.

User avatar
Hacker
Moderator
Moderator
Posts: 11398
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Moving all elements from selected folders into parent folder

Post by *Hacker » 2019-11-07, 21:23 UTC

leo007,
Ah, I see now. Thank you.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.

Post Reply