How can I copy a file that always changes file name?
Moderators: Dorian (MJT support), JRL
How can I copy a file that always changes file name?
Guys,
I'm looking to copy a file from one location to another. It's a WAV file that gets generated when using Cain & able when sniffing voip calls made from a system that automatically dials out a conference call.
The idea behind this is to make a copy of this file which its never the same name to a different path with a specific name.
Can anyone tell me what would be the best way to do this? vbscript or batch file?
Thanks,
Dannye
I'm looking to copy a file from one location to another. It's a WAV file that gets generated when using Cain & able when sniffing voip calls made from a system that automatically dials out a conference call.
The idea behind this is to make a copy of this file which its never the same name to a different path with a specific name.
Can anyone tell me what would be the best way to do this? vbscript or batch file?
Thanks,
Dannye
If the file size is always the same you could use GetFileList>c:\temp\*.wav,files to list the WAV files, then use FileSize> to find the file you're looking for.
Examples are in the help file
GetFileList> example
FileSize> Example
Examples are in the help file
GetFileList> example
Code: Select all
GetFileList>filespec,result[,delimiter]
GetFileList returns a list of the files found matching the specified filespec. For instance, to return the list of files in the temp directory specify c:\temp\*.* as the filespec.
If delimiter is ommitted each filename is separated by a semicolon (;). Otherwise the filenames are separated by the delimiter specified.
Abbreviation : GFL
Example
GetFileList>c:\temp\*.*,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
Let>k=0
Repeat>k
Let>k=k+1
Message>file_names_%k%
Until>k,file_names_count
Code: Select all
FileSize>filename,result
Returns the size of filename in the result variable.
The size is returned in bytes.
filename can include a full path.
Abbreviation : FSZ
See also : FileDate
Example
FileSize>c:\program files\myfile.exe,MyFileSize
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
What I would do is use GetFileList and store the result in an INI file. Each time compare the result with what was stored. That would tell me which file(s) is/are new. I then know which file to copy.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Or just look for the newest file in the directory. Examples to do that are on this forum.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Thanks for the reply JRL...JRL wrote:Here is one example.
I'm more than a newbie, so please bare with me on this... I used your sample and I'm sure I'm using it the wrong way. Can you please correct it for me?
-----
Run>cmd /c dir [C]:\[Program Files\Cain\VoIP] /o-d /b > [C]:\[Archive]\[list.txt]
ReadLn>[C]:\[Archive]\[list.txt],1,NewestFile
-----
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Take a look at:despinal wrote:Hey MTETTMAR, this would definitely work for me... I tried searching for such examples, but didn't find anything. Can you please help on this? thanks againmtettmar wrote:Or just look for the newest file in the directory. Examples to do that are on this forum.
Dannye
http://www.mjtnet.com/forum/viewtopic.php?t=3073
http://www.mjtnet.com/forum/viewtopic.php?t=1462
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
//RP_WAIT causes the script to pause until the external task completes
Let>RP_WAIT=1
//This is doing a dir in a DOS window. Set RP_WINDOWMODE=0 to not see
//the DOS window
Let>RP_WINDOWMODE=1
//You did not want the braces, they were there as standard nomenclature.
//DOS requires quotes around any location with spaces in the name.
//This will create a file "C:\Archive\list.txt" that is a list of all of the files
//at location "C:\[Program Files\Cain\VoIP". The list is sorted in descending
//date/time order
Run>cmd /c dir "C:\[Program Files\Cain\VoIP" /o-d /b > C:\Archive\list.txt
//This next line will set the variable "NewestFile" to the name of the newest
//file in the list that is file "C:\Archive\list.txt"
ReadLn>C:\Archive\list.txt,1,NewestFile
// The path and file name are now:
//C:\[Program Files\Cain\VoIP\%NewestFile%
// you can display this using MessageModal>
MessageModal>Newest file = C:\[Program Files\Cain\VoIP\%NewestFile%
Let>RP_WAIT=1
//This is doing a dir in a DOS window. Set RP_WINDOWMODE=0 to not see
//the DOS window
Let>RP_WINDOWMODE=1
//You did not want the braces, they were there as standard nomenclature.
//DOS requires quotes around any location with spaces in the name.
//This will create a file "C:\Archive\list.txt" that is a list of all of the files
//at location "C:\[Program Files\Cain\VoIP". The list is sorted in descending
//date/time order
Run>cmd /c dir "C:\[Program Files\Cain\VoIP" /o-d /b > C:\Archive\list.txt
//This next line will set the variable "NewestFile" to the name of the newest
//file in the list that is file "C:\Archive\list.txt"
ReadLn>C:\Archive\list.txt,1,NewestFile
// The path and file name are now:
//C:\[Program Files\Cain\VoIP\%NewestFile%
// you can display this using MessageModal>
MessageModal>Newest file = C:\[Program Files\Cain\VoIP\%NewestFile%
Thanks JRL... that did the trick and it's really simple...
....................
Let>RP_WAIT=1
Let>RP_WINDOWMODE=1
Run>cmd /c dir "C:\Program Files\Cain\VoIP" /o-d /b > C:\Archive\list.txt
ReadLn>C:\Archive\list.txt,1,NewestFile
MessageModal>Newest file = C:\Program Files\Cain\VoIP\%NewestFile%
....................
My last request: instead of showing me the "MessageModal" what command can I use to copy the newest file to another location? (example: C:\Archived)
By the way... where can I send you a donation to?
....................
Let>RP_WAIT=1
Let>RP_WINDOWMODE=1
Run>cmd /c dir "C:\Program Files\Cain\VoIP" /o-d /b > C:\Archive\list.txt
ReadLn>C:\Archive\list.txt,1,NewestFile
MessageModal>Newest file = C:\Program Files\Cain\VoIP\%NewestFile%
....................
My last request: instead of showing me the "MessageModal" what command can I use to copy the newest file to another location? (example: C:\Archived)
By the way... where can I send you a donation to?
Straight out of the help for Macro Scheduler:
CopyFile>C:\Program Files\Cain\VoIP\%NewestFile%,C:\Archived
Your line might be:CopyFile>sourcefile,destinationfile
Copies the file (or files), sourcefile, to destinationfile
Sourcefile, and destinationfile may be variables. Wildcards can be used.
By default if destinationfile already exists it will not be overwritten and the new file will be renamed appropriately. It is possible to change the bahaviour of the CopyFile command to overwrite instead by setting CF_OVERWRITE to 1. The default value of CF_OVERWRITE is 0.
Abbreviation : Cop
See also : MoveFile, DeleteFile, IfFileExists, AppendFile, RenameFile
Example
CopyFile>c:\temp\myfile.txt,c:\my documents\myfile.old
Or with variables:
Let>filename=c:\temp\myfile.txt
Let>newfilename=c:\temp\myfile.new
CopyFile>filename,newfilename
CopyFile>C:\Program Files\Cain\VoIP\%NewestFile%,C:\Archived