Page 1 of 1
Create file based on folder name and report folder contents
Posted: 07 Oct 2015 21:23
by hermhart
Hello, would anyone mind please taking a look at this and find the error in my ways. All I want this to do is to create a text file of the same name as the selected folder(s), then report the contents of the folder into the newly created text file. Thank you for any help that you can provide.
Code: Select all
$SelectedItems = get("SelectedItemsNames", "|");
foreach($Item, $SelectedItems, "|") {
$ItemName = regexreplace($Item, "(.+(?=\.))(.+)", "$1");
new($ItemName.".txt");
folderreport("filesrel", "f", $SelectedItems, "r", $ItemName.".txt",);
}
Re: Create file based on folder name and report folder conte
Posted: 07 Oct 2015 21:53
by highend
Code: Select all
foreach($folder, "<get SelectedItemsNames |>") {
if (exists("<curpath>\$folder") != 2) { continue; }
$logFileName = regexreplace($folder, "(.+(?=\.))(.+)", "$1") . ".txt";
if (exists("<curpath>\$logFileName") != 1) { new($logFileName); }
folderreport("filesrel", "f", "<curpath>\$folder", "r", "<curpath>\$logFileName",);
}
No time to make anything prettier...
Re: Create file based on folder name and report folder conte
Posted: 08 Oct 2015 12:19
by hermhart
highend,
I wasn't even close on what I had. Yours works like a charm. Thank you very much, I appreciate it.
Re: Create file based on folder name and report folder conte
Posted: 27 Oct 2015 14:41
by hermhart
Is there something that could be added to this script that would also copy the timestamp of each selected folder and use it as the timestamp for the newly created file?
Re: Create file based on folder name and report folder conte
Posted: 27 Oct 2015 15:04
by highend
Just add
Code: Select all
timestamp , "<curpath>\$folder", "<curpath>\$logFileName";
as the last line in the foreach() loop?
Re: Create file based on folder name and report folder conte
Posted: 27 Oct 2015 15:21
by hermhart
highend, I appreciate your help. Thank you.