FileConvertListing of Formats »
converts the contents of source to the format defined by the extension ext and writes the result to the file dest.ext.
writes the result to the filename defined by source, but with an extension defined by the specified format.
takes the contents of source to be in the specified format "format1".
Details and Options
- FileConvert can only be used to convert between compatible file formats, e.g. image file formats, audio file formats, etc.
- Files can be converted from formats supported by Import to formats supported by Export.
- Supported formats are listed in $ImportFormats and $ExportFormats.
- The format of a file is by default deduced by FileFormat.
- In FileConvert[source,…], source can be any of the following:
"file" or File["file"] file name, searched for on $Path "url" or URL["url"] HTTP, HTTPS or FTP URL
- The output from FileConvert is written in the current working directory specified by Directory.
- The following options can be given:
CreateIntermediateDirectories True whether to create intermediate directories OverwriteTarget True whether to overwrite an existing file
- FileConvert[url,…] accepts the following URLDownload options:
Authentication None authentication information to send CookieFunction Automatic function to apply to each cookie received ConnectionSettings Automatic speed and other settings for the connection FollowRedirects True whether to follow HTTP redirects Interactive True whether to allow interactive authentication dialogs TimeConstraint Infinity time to wait for a response VerifySecurityCertificates True whether to verify SSL security certificates
- In most cases, FileConvert is effectively equivalent to Export["file.ext",Import[source]].
Examplesopen allclose all
Basic Uses (6)
When no format is specified, FileConvert attempts to infer the format from the output file extension:
Specify the output file format:
When the output filename is not specified, the same filename is used with the new extension:
Specify the input and output formats:
Input and output formats can be specified regardless of extension:
Format Types (8)
Create an FLV file and convert to MP4, which requires a full FFmpeg installation:
Convert to "MP4":
By default, missing directories are created:
With CreateIntermediateDirectoriesFalse, missing directories are not created:
By default, FileConvert overwrites any existing output file:
Use OverwriteTargetFalse to prevent overwriting existing files:
Use FileSystemMap to convert an entire directory of a certain file type to a new format:
Possible Issues (4)
A file cannot be converted to an incompatible format:
FileConvert cannot create compressed archives:
Use CreateArchive to create compressed archives:
XLS and XLSX data is grouped into sheets and thus cannot be converted to CSV or TSV:
XLSX and XLS data can be efficiently converted sheet by sheet using Import and Export:
Wolfram Research (2019), FileConvert, Wolfram Language function, https://reference.wolfram.com/language/ref/FileConvert.html (updated 2020).
Wolfram Language. 2019. "FileConvert." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/FileConvert.html.
Wolfram Language. (2019). FileConvert. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FileConvert.html