Create .txt file from a folder and move it to location

Discuss and share scripts and script files...
Post Reply
Ysl
Posts: 150
Joined: 03 Jan 2007 22:22

Create .txt file from a folder and move it to location

Post by Ysl »

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 :) :)

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Create .txt file from a folder and move it to location

Post by highend »

Something like this?

Test it, before you use it with real data!

Code: Select all

    $dstPath = "F:\Dummy Files";
    foreach($item, <get SelectedItemsPathNames <crlf>>, <crlf>, "e") {
        if (exists($item) == 1) { continue; }
        $dstFile = "$dstPath\FOLDER_" . gpc($item, "component", -1) . ".txt";
        new($dstFile, "file");
        delete 1, 0, $item;
    }
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

Ysl
Posts: 150
Joined: 03 Jan 2007 22:22

Re: Create .txt file from a folder and move it to location

Post by Ysl »

Looks like it work perfectly as I wanted :)
THANK YOU VERY MUCH !!

Post Reply