Rename file by file size

Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
3 posts Page 1 of 1


Posts: 2
Joined: Thu Jan 02, 2014 9:51 am

Post by Jlipp » Thu Jan 02, 2014 10:14 am
I have a two files that we pull from a system that are typically named with just numbers. I want to drop these two files int a monitored folder and when both are in there to rename and send them.

There is no consistency in the numbers that come out of our system so I really can't base the file name change on the incoming file name. I need to change the file names based on file size. One is always under 200 KB and the other is always over 1 MB.

I've looked through a lot of the documentation and haven't found anything in regards to making fie name changes based only on file size. Has anyone done this or know if this is an option?


Support Specialist
Posts: 592
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Thu Jan 02, 2014 10:28 am

When you have a filelist variable (created from a Monitor or CreateFileList task, etc) you have access to the File Attributes. By putting the FileList variable into a ForEach loop, you can test for file size with something like this:
Code: Select all
<forEachLoop label="Loop through list of Docs" itemsVariable="${lsFiles}" currentItemVariable="file">

			<setVariable label="Set File Name" name="stat_filename" value="${ file:name }" version="2.0" />
			<setVariable label="Set File Size" name="stat_filesize" value="${ file:size }" version="2.0" />

Or, utilize the "FileInfo" function if you already have the file path/name inside a variable:
Code: Select all
	<variable name="FileName1" value="\Temp\1.jpg" />
	<variable name="FileName2" value="\Temp\2.jpg" />
		<if label="Compare File Size" condition="${ ( FileInfo( String( FileName1 ) ):size ) == ( FileInfo( String( FileName2 ) ):size ) }">

Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696


Posts: 2
Joined: Thu Jan 02, 2014 9:51 am

Post by Jlipp » Fri Jan 03, 2014 12:30 pm
I ended up using a couple of if statements and some other workarounds, but ended up getting it work. Thanks for the help!
3 posts Page 1 of 1