Delete all except files/folders starting with hash

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
acicovic
Posts: 42
Joined: 31 Oct 2017 19:52

Delete all except files/folders starting with hash

Post by acicovic »

Hi,

I have a deep folder/file structure with thousands of files. I will be renaming certain files and folders with a hash character at the beginning of their filename. Then, I would like to delete all files and folders except the files/folders starting with a hash, keeping the folder structure intact for those files.

I hope what I say is clear.

Is there a fast way to do this with XYplorer?

Thanks!

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

Re: Delete all except files/folders starting with hash

Post by highend »

I hope what I say is clear.
No

What happens with subfolders of folders that start with a hash or files in them?

Code: Select all

.\#root
.\#root\no_hash_folder -> To be deleted?
.\#root\no_hash_folder\no_hash_file.ext -> To be deleted?
One of my scripts helped you out? Please donate via Paypal

acicovic
Posts: 42
Joined: 31 Oct 2017 19:52

Re: Delete all except files/folders starting with hash

Post by acicovic »

Hi,

Thanks for asking, this way it's clearer. Any files or folders within a folder starting with a hash should not be deleted.

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

Re: Delete all except files/folders starting with hash

Post by highend »

Then you could write a simple script that collects all folders, remove those that DO NOT start with a hash,
loop over the remaining ones, find all files and then delete all of them that don't start with a hash.

In a last step you could also remove those folders (not starting with a hash) that don't contain files
any more...
One of my scripts helped you out? Please donate via Paypal

acicovic
Posts: 42
Joined: 31 Oct 2017 19:52

Re: Delete all except files/folders starting with hash

Post by acicovic »

Hi, thanks for your input. I'll see if I'll resort to scripting as I'm not that comfortable with it yet (I wrote my first script yesterday).

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

Re: Delete all except files/folders starting with hash

Post by highend »

I wrote my first script yesterday
Perfect start to dive in deeper :tup:
One of my scripts helped you out? Please donate via Paypal

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

Re: Delete all except files/folders starting with hash

Post by highend »

And, any progress?
One of my scripts helped you out? Please donate via Paypal

acicovic
Posts: 42
Joined: 31 Oct 2017 19:52

Re: Delete all except files/folders starting with hash

Post by acicovic »

Hi !

I've been too busy with other stuff so I haven't even tried for the time being.

Post Reply