Community discussions

MikroTik App
 
planetcaravan
Member Candidate
Member Candidate
Topic Author
Posts: 267
Joined: Tue Aug 25, 2009 5:33 pm

Automatic file extension

Sat Oct 20, 2012 12:27 pm

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?
 
samsung172
Forum Guru
Forum Guru
Posts: 1191
Joined: Sat Apr 04, 2009 3:45 am
Location: Østfold - Norway
Contact:

Re: Automatic file extension

Sat Oct 20, 2012 9:35 pm

?, use file=xxxxxxxxxx.yyy

eg :

ros code

export file=backup.rsc
export compact file=backup.txt
 
User avatar
c0d3rSh3ll
Long time Member
Long time Member
Posts: 557
Joined: Mon Jul 25, 2011 9:42 pm
Location: [admin@Chile] >

Re: Automatic file extension

Sat Oct 20, 2012 9:43 pm

?, use file=xxxxxxxxxx.yyy

eg :

ros code

export file=backup.rsc
export compact file=backup.txt

you try this?
always save backup and export in .backup or .rsc
 
planetcaravan
Member Candidate
Member Candidate
Topic Author
Posts: 267
Joined: Tue Aug 25, 2009 5:33 pm

Re: Automatic file extension

Sat Oct 20, 2012 9:58 pm

How can I create a file and choose my extension?
 
User avatar
c0d3rSh3ll
Long time Member
Long time Member
Posts: 557
Joined: Mon Jul 25, 2011 9:42 pm
Location: [admin@Chile] >

Re: Automatic file extension

Sat Oct 20, 2012 10:05 pm

what extension need?
 
planetcaravan
Member Candidate
Member Candidate
Topic Author
Posts: 267
Joined: Tue Aug 25, 2009 5:33 pm

Re: Automatic file extension

Sat Oct 20, 2012 10:07 pm

any one... html for example
 
planetcaravan
Member Candidate
Member Candidate
Topic Author
Posts: 267
Joined: Tue Aug 25, 2009 5:33 pm

Re: Automatic file extension

Sat Oct 27, 2012 2:18 pm

Can somebody help me?
 
gerardr
just joined
Posts: 3
Joined: Fri Jan 10, 2014 1:06 am

Re: Automatic file extension

Fri Jan 10, 2014 1:15 am

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?
 
gerardr
just joined
Posts: 3
Joined: Fri Jan 10, 2014 1:06 am

Re: Automatic file extension

Fri Jan 10, 2014 1:20 am

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?
 
User avatar
zap71
Frequent Visitor
Frequent Visitor
Posts: 83
Joined: Fri Sep 27, 2013 11:10 am
Location: Berlin, Germany
Contact:

Re: Automatic file extension

Fri Jan 10, 2014 10:02 am

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.
 
gerardr
just joined
Posts: 3
Joined: Fri Jan 10, 2014 1:06 am

Re: Automatic file extension

Fri Jan 10, 2014 8:23 pm

@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.
 
User avatar
zap71
Frequent Visitor
Frequent Visitor
Posts: 83
Joined: Fri Sep 27, 2013 11:10 am
Location: Berlin, Germany
Contact:

Re: Automatic file extension

Fri Jan 10, 2014 8:35 pm

Ha what a cool idea! :D

Zap.
 
dfdf
newbie
Posts: 36
Joined: Wed Dec 08, 2021 3:51 pm

Re: Automatic file extension

Wed Nov 22, 2023 10:00 pm

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"]

Who is online

Users browsing this forum: No registered users and 7 guests