I need a Scrypt Badly i need find copy and rename

Discuss and share scripts and script files...
Post Reply
chupa_cabra
Posts: 2
Joined: 18 Oct 2012 22:16

I need a Scrypt Badly i need find copy and rename

Post by chupa_cabra »

I need a script that can find and copy multiple files from a directory and as well stored them into another computer plus also rename them when they get copied so let me do an example.

I want a index.dat file to be scanned from a directory like C:Documents and settings etc.

Then after finding them all send to another folder in another computer and name it the same from the folder it came from so if the index.dat file came from a support or from lending i want it to say support.dat or lending.dat which ever it came from.

I know it might not be possible to do all in one but if i can get the script for one i can just edit the rest of them.

so to make it more easy i broke it down a little better.

Find index.dat from directory
after finding the index.dat files copy and send to another location to another pc.
Rename the files from the original folder it came from.

or if anyone has a similar scrypt im willing to work with i just need to find something i can start off with.

Thank you in advanced.

highend
Posts: 14942
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: I need a Scrypt Badly i need find copy and rename

Post by highend »

Code: Select all

$dirToScan = "D:\Temp"; // Root dir to scan for files on the local PC
	$destDir = "\\bk-dt-01\storage"; // The remote PC with a shared directory name
	$fileToFind = "index.dat"; // File name that will be searched

	$files = folderreport("files", "r", $dirToScan, "r", , "|");
	$files = formatlist($files, "f", "|", "*$fileToFind");

	foreach($entry, $files, "|") {
		$parentDir = getpathcomponent($entry, "parent");
		$fileName = getpathcomponent($entry, "file");
		copyto $destDir, $entry;

		while(exists("$destDir\$fileName") == 0) {
			wait 500;
		}
		rename b, "$parentDir", , "$destDir\$fileName";
	}
Works for me...

Make sure you have write permissions on that share otherwise the while loop will run forever (and freeze your XYplorer instance) *g*
One of my scripts helped you out? Please donate via Paypal

chupa_cabra
Posts: 2
Joined: 18 Oct 2012 22:16

Re: I need a Scrypt Badly i need find copy and rename

Post by chupa_cabra »

Ok thanks looks like this is exactly what i needed.

But one more thing i want to ask is there a way to export this into a .bat file and run it off without the explorer and just use windows.

that way i can use it in multiple pc's cause i got a lot of them i have to go through and i don't have xyplorer installed on all of them.

by the way thank you for your response i appreciate it greatly.

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: I need a Scrypt Badly i need find copy and rename

Post by j_c_hallgren »

chupa_cabra wrote:But one more thing i want to ask is there a way to export this into a .bat file and run it off without the explorer and just use windows.
This is a XY script and as such, requires XY to function...Just like you can't run a Excel macro without Excel.
that way i can use it in multiple pc's cause i got a lot of them i have to go through and i don't have xyplorer installed on all of them.
You don't have to install XY on them...just run it from a USB drive/stick....script might need to be tweaked if used as such, but that's just a caution from me who's NOT a XY scripter.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

Post Reply