Moving files but keeping parent name

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
CookieMonster

Moving files but keeping parent name

Post by CookieMonster »

I want to move files from multiple sub-folders of the same name, to another folder on another drive; but create new sub-folders in the other folder for which the files are moved too, but with the same name of the parent folder name for which the files are moving from.

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Moving files but keeping parent name

Post by highend »

And?

Define a $src and a $dst folder
Count the number of "\" via gettoken() for $src
Get the necessary folders from $src via quicksearch()

The foreach loop:
Count the number of "\" for the current folder and compare it with the value from above and skip via continue
(the first layer of folders should not be processed)!
Get the parent of each folder via getpathcomponent()
Get each folder's files via quicksearch() or listfolder()
Construct the final destination path and move them via moveto

Go for it...
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: Moving files but keeping parent name

Post by CookieMonster »

$src & $dst are variables, not known variables, correct ?

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Moving files but keeping parent name

Post by highend »

What are "known variables"?
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: Moving files but keeping parent name

Post by CookieMonster »

Where can I find, known variables in the documentation ?

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Moving files but keeping parent name

Post by highend »

Advanced Topics - Variables? oO
One of my scripts helped you out? Please donate via Paypal

Post Reply