Convert a (filename.001) to (filename.txt)

55 views (last 30 days)
BEN
BEN on 24 Feb 2014
Commented: Image Analyst on 20 Sep 2018
Hi,
I'm asking for some one who can help me to convertan image file which have an extension .001 to a image file .txt
the name of the file is: 02241625.001
think's ;-)

Answers (2)

Azzi Abdelmalek
Azzi Abdelmalek on 24 Feb 2014
Edited: Azzi Abdelmalek on 24 Feb 2014
file1='02241625.001'
file2=strrep(file1,'.001','.txt')
copyfile(file1,file2)
  2 Comments
Muhammad Zayed
Muhammad Zayed on 20 Sep 2018
Worked perfectly for my application. I wanted to create an exact copy of (.lvm) file but save it as (.txt) file. Thank you!
Image Analyst
Image Analyst on 20 Sep 2018
You could also look at my answer, which will work for ANY extension, like your .lvm extension, not just .001 extensions.

Sign in to comment.


Image Analyst
Image Analyst on 24 Feb 2014
Try this:
% Create sample filename.
filename = '02241625.001'
[folder, baseFileName, extension] = fileparts(filename)
% Ignore extension and replace it with .txt
newBaseFileName = sprintf('%s.txt', baseFileName)
% Make sure the folder is prepended (if it has one).
newFullFileName = fullfile(folder, newBaseFileName)
It will work for any extension whatsoever. Whatever is there (numbers, letters) gets replaced by txt.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!