Dear colleagues,
I am new to the forum and have started using Xy. I want to be able to select certain named pdf files from a folder based on the first name of the file which would be in a list that I can nopy to clipboard/put on text file or excel.
I am hoping the gods out there can explain this for me. I have high hopes in being able to do this as it will save me my job.
Extracting files from a folder based on criteria in a file
-
4run
- Posts: 2
- Joined: 05 Jun 2014 17:28
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Extracting files from a folder based on criteria in a fi
There is not really much information about the file names so...
Go into the folder that contains the .pdf files.
Copy the list of names into the clipboard (each name must be on it's own line!)
Execute this script.
It _should_ select the necessary files.
The delimiter between the first and the second part of a filename has to be a space / tab.
And yes, coded in a hurry^^
Code: Select all
$names = regexmatches("<clipboard><crlf>", "^.*?(?=\s)", "|");
foreach($item, listfolder("<curpath>", "*.pdf", 5), "|") {
$firstPart = regexreplace($item, "(^.*?(?=\s)).*", "$1");
foreach($name, $names, "|") {
if ($name LikeI $firstPart) {
selectitems $item, , , "a";
}
}
}
Copy the list of names into the clipboard (each name must be on it's own line!)
Execute this script.
It _should_ select the necessary files.
The delimiter between the first and the second part of a filename has to be a space / tab.
And yes, coded in a hurry^^
One of my scripts helped you out? Please donate via Paypal
XYplorer Beta Club