Hi there,
I’ve noticed that each time I create a new file, RouterOS automatically adds a “.txt” extension.
How can I change this behavior as is not possible to rename file?
Hi there,
I’ve noticed that each time I create a new file, RouterOS automatically adds a “.txt” extension.
How can I change this behavior as is not possible to rename file?
?, use file=xxxxxxxxxx.yyy
eg :
export file=backup.rsc
export compact file=backup.txt
you try this?
always save backup and export in .backup or .rsc
How can I create a file and choose my extension?
what extension need?
any one… html for example
Can somebody help me?
I’m having the same problem. I want to create a file called “radio.inf” from a script, and I can’t find a way to do that.
Can anyone form Mikrotik comment on this issue?
I’m having the same problem. I want to create a file called ‘radio.inf’ and I can’t find a way to do this.
Can someone from Mikrotik comment on this issue?
I think it depends on how you want to create “a file”.
You can not modify the extension of “known” file types like exports or backups.
If the filename is a custom file, like e.g.
/tool fetch url="http://www.google.de/" mode=http dst-path=test.abc
you can choose the filename yourself.
Zap.
@zap71, Your post prompted me to try using the fetch command. Since my script runs when the radio is not connected to the Internet, I can’t fetch the file from a remote server. Instead, I used the fetch command to copy the .txt file to a .inf file on the radio, and then remove the .txt file that is no longer useful. My full implementation is as follows:
:local TxtFile "radio.txt"
:local InfFile "radio.inf";
# Create the .txt file
/file print file=$TxtFile
:delay 1
# Update the file contents
/file set $TxtFile contents="Some content"
# Copy the .txt file to the .inf file
/tool fetch address=127.0.0.1 user=admin password="" src-path=$TxtFile mode=ftp upload=no dst-path=$InfFile
# Remove the .txt file that is no longer needed
/file remove $TxtFile
A bit kludgy, but it meets my requirements. Note that the :delay command is needed to give the radio time to create the file before updating it with the custom content.
Ha what a cool idea! ![]()
Zap.
old topic, but for someone who will search for a solution in the future:
you should append zero symbol (“\00”) to the end of the string to prevent .txt extension addition
examples:
:local $"myFileNameWithMyExtension" "myFile.anyext";
usage:
/file print file=($"myFileNameWithMyExtension"."\00");
or
/system script print without-paging file=($"myFileNameWithMyExtension"."\00") where name="MyScript";
etc…
NB: DO NOT use “\00” in get clause, just use $“myFileNameWithMyExtension” to check for file properties, ie:
:put [/file get $"myFileNameWithMyExtension" value-name="size"]
As syntax from previous post not valid at least in RoS 7.19.4 +
Posting working example.
:global StoragePath "flash/"
:global FileName "id_ed25519-user.pub"
/file print file=("$StoragePath"."$FileName"."\00")
When you make a necropost from 2 YEARS OLD post to correct someone, you're also must correcting yourself...
...or at least add something useful...
Since 7.16.2 (if not earlier, I don't have any older versions handy), you can create a file with the desired extension... more simply.
/file add name="myfile.myext"
or for force RouterOS for not assign standard file names on export, backup, etc. (completely meaningless to me)
(this for both v6 and v7)
/export file="exportname.myext\00"
/system backup save name="backupname.myext\00"
instead can be useful for create csv file
(also this for both v6 and v7)
# if must be ,
:execute ":put \"a,b\r\nc,d\"" file="filename.csv\00"
# if must be ;
:execute ":put \"a;b\r\nc;d\"" file="filename.csv\00"
Of course, :put "a,b\r\nc,d" can be replaced with any script, or script call, that generates a much more complex CSV file than this example.
It can also be used to create custom .rsc files, not just those created with export, etc., etc., etc.