Create .txt file from a folder and move it to location
Posted: 17 Feb 2021 13:16
Hi all my helping script Gurus friends !
I got from you, some years ago, a script that selected a file, changed the extension to .txt, moved it into a folder, then deleted the original file.
It work very well but now I am looking for the same thing but for a Folder
The script should do this
Take the name of the selected folder, create a .txt file and append 'FOLDER to it at the beginning of the name, move that .txt file to "F:\Dummy Files" and the delete the original folder and its content.
Here is the original script for Files to help you so you should only modify a few lines... :
End GetInfo("CountSelected") < 1, "No item(s) selected.";
Global $files;
$files = Report("{Dir |{FullName};{Ext}<crlf>|}", 1);
Setting "AllowRecursion", 1;
Sub "_newTXT";
$files = RegexReplace($files, "^(.*);.*<crlf>", "$1|");
Delete 1,0,$files;
sel 1;
"_newTXT"
Global $files, $i;
$i = $i Like "" ? 1 : $i;
$token = GetToken($files, $i, "<crlf>");
End $token Like "",, 1;
$file = GetToken($token, 1, ";");
$ext = GetToken($token, 2, ";");
$newFile = RegexReplace($file, "$ext$", "txt");
New ("$newFile");
$i = $i + 1;
Sub "_newTXT";
moveto "F:\Dummy Files", $newFile;
Thank you in advance for your help
I got from you, some years ago, a script that selected a file, changed the extension to .txt, moved it into a folder, then deleted the original file.
It work very well but now I am looking for the same thing but for a Folder
The script should do this
Take the name of the selected folder, create a .txt file and append 'FOLDER to it at the beginning of the name, move that .txt file to "F:\Dummy Files" and the delete the original folder and its content.
Here is the original script for Files to help you so you should only modify a few lines... :
End GetInfo("CountSelected") < 1, "No item(s) selected.";
Global $files;
$files = Report("{Dir |{FullName};{Ext}<crlf>|}", 1);
Setting "AllowRecursion", 1;
Sub "_newTXT";
$files = RegexReplace($files, "^(.*);.*<crlf>", "$1|");
Delete 1,0,$files;
sel 1;
"_newTXT"
Global $files, $i;
$i = $i Like "" ? 1 : $i;
$token = GetToken($files, $i, "<crlf>");
End $token Like "",, 1;
$file = GetToken($token, 1, ";");
$ext = GetToken($token, 2, ";");
$newFile = RegexReplace($file, "$ext$", "txt");
New ("$newFile");
$i = $i + 1;
Sub "_newTXT";
moveto "F:\Dummy Files", $newFile;
Thank you in advance for your help