Move a file, in alphabetical order

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
lebrocoli
Pro Scripter
Posts: 53
Joined: Tue Sep 06, 2005 9:28 pm

Move a file, in alphabetical order

Post by lebrocoli » Mon Oct 15, 2007 9:00 pm

Me again.

Ok. I have looked for many move file topics and I can now move all the files within a directory.

But a question remains:

I have a directory of files.

Let's say DirectoryA with File1, File2 and File3.

DirectoryA
File1
File2
File3

What I need to do is move the first file, File1 to Directory B, then File2, then File3.

The order is important. Now, there are a lot of commands like filedate, filesize, filetime, but me, I need to move files by filenames! I mean the first one in the directory, then the 2nd one, etc.

let's assume that I cannot rename the files.

Once I have my 'files' variable filled in with my file names how can I send the first one in the list ? Is there an index I can used with the GetFileList command ?


GetFileList>%BeaconFolder%*.txt,files
Separate>files,;,file_names
Let>k=0
Repeat>k
Let>value=filename_%k% -> I would like to NOT use that line

Thanks

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Oct 16, 2007 7:44 am

You just need to sort the array:
http://www.mjtnet.com/forum/viewtopic.php?t=3414
http://www.mjtnet.com/forum/viewtopic.php?t=4063

They will then be in alphabetical order and you can go down from top to bottom in the usual way, by index.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

lebrocoli
Pro Scripter
Posts: 53
Joined: Tue Sep 06, 2005 9:28 pm

Post by lebrocoli » Tue Oct 16, 2007 5:26 pm

Ok thanks!.

That said, being a beginner, I have no clue when you say "...in the usual way, by index."

Would it be possible to give me an example on let's say how to get the first item one the filelist?

Thanks

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Oct 16, 2007 5:28 pm

Well, you already posted the code to do that but for some reason you say you don't want to do it:

Let>item=file_names_1
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

lebrocoli
Pro Scripter
Posts: 53
Joined: Tue Sep 06, 2005 9:28 pm

Post by lebrocoli » Tue Oct 16, 2007 7:10 pm

Ok, I just understand.

Thanks

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Oct 16, 2007 7:33 pm

Can you tell us why the order in which the files are copied is important?

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Oct 16, 2007 7:37 pm

That question occured to me too. Since the order files are copied will make no difference to the order they are stored, or seen. So I assumed the op just wants to copy the first one or few - alphabetically. If copying the lot there is absolutely no point in doing it in any order.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

lebrocoli
Pro Scripter
Posts: 53
Joined: Tue Sep 06, 2005 9:28 pm

Post by lebrocoli » Tue Oct 16, 2007 9:20 pm

Ok works now.

The order is important because they are distress beacon files. So they have to be sent (moved) as they come in. In a real system, they come in one at a time and the system read them one at a time.

In testing, when I 'replay' the thing, I have all my beacon text files in a folder and I need to send them in order they would arrive in reality. When the files arrive, their filename contains text but also a unique number that is incremented for each file.

Regards.

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Tue Oct 16, 2007 9:59 pm

Me_again wrote:Can you tell us why the order in which the files are copied is important?
Hi lebrocoli,

I was curious about this too. Are you concerned with what order they might appear when you do some sort of directory listing or... is it something to do with the actual Creation Dates of the copied files or...?
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Oct 16, 2007 10:48 pm

lebrocoli wrote:The order is important because they are distress beacon files. So they have to be sent (moved) as they come in. In a real system, they come in one at a time and the system read them one at a time.

In testing, when I 'replay' the thing, I have all my beacon text files in a folder and I need to send them in order they would arrive in reality. When the files arrive, their filename contains text but also a unique number that is incremented for each file.

Regards.
Understood, thanks for the info!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts