ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Coding Snacks

[Complete] Consolidate files in the parent folder

<< < (2/3) > >>

Target:
you're most welcome Carol!!

i did consider what Mouser said, but you'd already said the filenames were all unique (I could change it to cater for that if you want...)

and thanks for the credits (not necessary, but appreciated)

exold:
If you're trying to do this somewhere you only have access to CMD.EXE, I'm pretty sure you can use FOR..IN..DO to get the job done. It's a little-known tool that provides a lot of powerful functionality. The UI is crap, though.... :P

bootz15:
This is awesome! I would really like to see the code that assumes the sub-files are not uniquely named, too.

Ampa:
In Xplorer2 you can flatten a folder structure by selecting the folder and pressing Shift+Enter. This shows all files within the folder and subfolders in a single pane, at which point you can move / rename or do anything else with them.

Perhaps DOpus has something similar?

vixay:
I have done some more modifications to suit my purpose, which was to rename the files to include the folder path it had.
i.e.
root
 a
   1
 b
   1
   2

--- End quote ---
would become
root
a-1
b-1
b-2

--- End quote ---

here's the code for it
FlattenWithFolderNames.ahk

--- ---fileselectfolder,MyFold,::{20d04fe0-3aea-1069-a2d8-08002b30309d}
SetWorkingDir, %MyFold%
loop, *.*,0,1
{
parentpath := RegExReplace(A_LoopFileDir,"\\","-")
;StringReplace, parentpath, A_LoopFileDir, \,-,All
newname = %parentpath%-%A_LoopFileName%
;msgbox %newname%
If a_loopfiledir <>
filemove, %a_loopfilefullpath%,%newname%
}

loop, %myfold%\*.*,2,1
fileremovedir, %a_loopfilefullpath%,1

exitapp

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version