Hi all
I have a folder that contains many files,
and I want to clean the filenames of these files from problematic chars,
and only leave chars that I will define in a White List of chars,
for example:
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890()-_."
All other chars will be deleted from the filenames..
Can XYplorer can do this automatically on a folder, If I provide the White List of chars?
Thank you
How to Clean the Filenames of Files in a Folder, According to a white List of Chars, Automatically?
Re: How to Clean the Filenames of Files in a Folder, According to a white List of Chars, Automatically?
With a script that would loop over all files in that folder, check the names and remove the chars and that one bound to a CEA: Changing locations
It would at least be triggered once you switch to that folder...
It would at least be triggered once you switch to that folder...
One of my scripts helped you out? Please donate via Paypal
-
- Site Admin
- Posts: 60635
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: How to Clean the Filenames of Files in a Folder, According to a white List of Chars, Automatically?
If it's just one folder as I understand, CEA is not necessary. Look at scripting command
rename k ...
FAQ | XY News RSS | XY Twitter
Re: How to Clean the Filenames of Files in a Folder, According to a white List of Chars, Automatically?
Thank you very much regarding
What is CEA?
The documentation does not mention this term..
The folder has some sub-folders,
so iterating it recursivly would be nice,
but even If not, I can manually execute it on each of the folders myself,
since the total number of folders is not big.
BTW,
when I supply the list of Allowed Chars to
how do I prevent some chars from being interpreted as a part of the command?
(e.g. ',' for example)
I need the command to understand all the chars as the chars in the Allow List,
and that no char will "break" or ruin the syntax of the line..
rename k
.What is CEA?
The documentation does not mention this term..
The folder has some sub-folders,
so iterating it recursivly would be nice,
but even If not, I can manually execute it on each of the folders myself,
since the total number of folders is not big.
BTW,
when I supply the list of Allowed Chars to
rename k
,how do I prevent some chars from being interpreted as a part of the command?
(e.g. ',' for example)
I need the command to understand all the chars as the chars in the Allow List,
and that no char will "break" or ruin the syntax of the line..
-
- Site Admin
- Posts: 60635
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: How to Clean the Filenames of Files in a Folder, According to a white List of Chars, Automatically?
Quote them, this gives you a preview before committing the rename:
Code: Select all
rename k, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890()-_.", p;
FAQ | XY News RSS | XY Twitter
Re: How to Clean the Filenames of Files in a Folder, According to a white List of Chars, Automatically?
Can the rename command perform 2 modes on 1 execution?
For example:
Search and Replace:
And:
I can do it with 2 commands,
but doing it with 2 commands has 2 problems:
The first (the small problem) is that it will go over all files twice, in order to rename them,
and the second (the biggerl problem) is that I can't have the preview on the total change that will happen..
I can only have a preview twice, or a preview on the last 1 (mode k), butout the change in mode s.
So does the syntax allow tosomehow combine more than 1 mode, into 1 command?
For example:
Search and Replace:
Code: Select all
rename s, "[]{};,!>_"
Code: Select all
rename k, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890()-_.", p;
but doing it with 2 commands has 2 problems:
The first (the small problem) is that it will go over all files twice, in order to rename them,
and the second (the biggerl problem) is that I can't have the preview on the total change that will happen..
I can only have a preview twice, or a preview on the last 1 (mode k), butout the change in mode s.
So does the syntax allow tosomehow combine more than 1 mode, into 1 command?
Re: How to Clean the Filenames of Files in a Folder, According to a white List of Chars, Automatically?
I hope this will help you.
Code: Select all
$names = "";
foreach($item, <selitems <crlf>>, <crlf>, "e") {
$str = gpc($item, "file");
$str = regexreplace("$str", "[\[|\]||{|}|;|,\!]", "_");
$str = regexreplace("$str", "[^a-zA-Z0-9\(\)-_\.]", "");
$names .= $str . <crlf>; }
rename "l", $names, p, , 64;
Last edited by yusef88 on 07 Apr 2023 13:02, edited 1 time in total.
Re: How to Clean the Filenames of Files in a Folder, According to a white List of Chars, Automatically?
Hi Yusef
Thank you very much.
It's nice that you get along well with RegEx,
most people are detered by them..
Thank you very much.
It's nice that you get along well with RegEx,
most people are detered by them..
Re: How to Clean the Filenames of Files in a Folder, According to a white List of Chars, Automatically?
actually, I'm not experienced in regex. the script belongs to highend. viewtopic.php?p=193995#p193995
I post it as example how to do rename in one go (regex maybe inaccurate)
I post it as example how to do rename in one go (regex maybe inaccurate)
Re: How to Clean the Filenames of Files in a Folder, According to a white List of Chars, Automatically?
Oh
Still, most people (inc. me) are deterred from RegEx.
You seem to not be.
Still, most people (inc. me) are deterred from RegEx.
You seem to not be.