1. Changing file types
- Posted by Michael <mb7001 at earthlink.net> Jul 16, 2001
- 486 views
Hi, I am new to the list, and new to Euphoria. It is great to see a language that is easy to pick up and powerful at the same time. My problem is that I am going to be using some new graphical software, and the old software saved my files as a .sci type. What I want to do is to change all of those files into a .epu type. I have so many that I was hoping I could write a program to get the job done. My question is: Is it possible to do? I already know that just by changing the extension the file will work in my new software. Also is there any euphoria programs already written to do this? Thanks Michael
2. Re: Changing file types
- Posted by Derek Parnell <ddparnell at bigpond.com> Jul 16, 2001
- 464 views
Hi Michael, if you have Windows ME or Windows 2000, you can do this is a DOS window. Enter the command below in the directory where the .sci files are... for %d in (*.sci) do @move "%~Pnxd" "%~Pnd.epu" If you have older versions of DOS/Windows then you can still do this... Step 1) If a DOS window use this command in the directory of the .sci files. for %d in (*.sci) do @echo >>x.bat move "%d" "%dX" Step 2) Use your favourite editor and edit x.bat. Change all '.sciX' into '.epu' Save the x.bat file Step 3) Run the x.bat file in the same directory. ----------- cheers, Derek Parnell Senior Design Engineer Global Technology Australasia Ltd dparnell at glotec.com.au --------------------- confidential information intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient of this message you are hereby notified that any use, dissemination, distribution or reproduction of this message is prohibited. If you have received this message in error please notify the sender immediately. Any views expressed in this message are those of the individual sender and may not necessarily reflect the views of Global Technology Australasia Limited.
3. Re: Changing file types
- Posted by Travis Beaty <travis_n_marylou at yahoo.com> Jul 16, 2001
- 472 views
Howdy, and welcome to the Grand Euphorium, Michael. > I am new to the list, and new to Euphoria. It is great to see a > language that is easy to pick up and powerful at the same time. My > problem is that I am going to be using some new graphical software, and > the old software saved my files as a .sci type. What I want to do is to > change all of those files into a .epu type. I have so many that I was > hoping I could write a program to get the job done. My question is: Is > it possible to do? I already know that just by changing the extension > the file will work in my new software. Also is there any euphoria > programs already written to do this? > Thanks > Michael Well, in Euphoria, you can use dir() to get names of all the files in the directory ... you can look up the specifics of that command in the Euphoria Standard Library documentation. Once you have the file name, you can do something like this ... Remember that I'm coding this off the cuff, so it is very untested, but should give you an idea. -- start of code -- This function will replace the file's current extension with the extension provided in sNewExtension. -- Will return the file name with the new extension if successful, otherwise an empty sequence. function changeExtension(sequence sFileName, sequence sNewExtension) sequence sNewName integer iMatchLoc -- Safety check on the parameters if (not length(sFileName)) or (not length(sNewExtension)) then return {} end if -- Initialize our new file name variable sNewName = {} -- Turn the filename backwards, so that "test.sci" would become "ics.tset" sFileName = reverse(sFileName) -- Find the "." that marks the beginning of the extension. iMatchLoc = find('.', sFileName) -- At this point there could either be an extension on the file name, or not. We deal with both cases and -- load the reversed file name (without extension) into sNewName. if iMatchLoc = 0 then sNewName = sFileName else sNewName = sFileName[iMatchLoc .. length(sFileName)] end if -- Flip the file name around again. sNewName = reverse(sNewName) -- If the file was "test.sci", then the value of sNewName is now "test." Now we just add the extension. sNewName &= sNewExtension -- If sNewExtension was "epu", then we now have "test.epu." So our function needs to return that. return sNewName end function -- end untested code. There you go. Remember that this code might have some bugs, and not check for certain situations, however it will give you the gist of what has to be done. Travis Beaty Claude Texas (for another 3 weeks or so)
4. Re: Changing file types
- Posted by Lewis Townsend <keroltarr at HOTMAIL.COM> Jul 17, 2001
- 453 views
Hello, > for %d in (*.sci) do @move "%~Pnxd" "%~Pnd.epu" > for %d in (*.sci) do @echo >>x.bat move "%d" "%dX" whats wrong with the DOS command: ren *.sci *.epu I haven't actually tested this but it makes sense to me. later, Lewis Townsend
5. Re: Changing file types
- Posted by Derek Parnell <ddparnell at bigpond.com> Jul 17, 2001
- 473 views
Thanks Lewis, I didn't know that. I've re-read the docs on REN and it doesn't really suggest you can do that but it works. ----- Original Message ----- From: "Lewis Townsend" <keroltarr at HOTMAIL.COM> To: "EUforum" <EUforum at topica.com> Subject: Re: Changing file types > > > Hello, > > > > for %d in (*.sci) do @move "%~Pnxd" "%~Pnd.epu" > > for %d in (*.sci) do @echo >>x.bat move "%d" "%dX" > > whats wrong with the DOS command: > > ren *.sci *.epu > > I haven't actually tested this but it makes sense to me. > > later, > Lewis Townsend > > > >
6. Re: Changing file types
- Posted by Lewis Townsend <keroltarr at HOTMAIL.COM> Jul 17, 2001
- 474 views
Hello Derek, >Thanks Lewis, >I didn't know that. I've re-read the docs on REN and it doesn't really >suggest you can do that but it works. Cool, actually it surprises me a little that it works without modification. I know that the following senario doesn't always work. files in current directory file01.bmp file02.bmp file03.bmp ... fileXX.bmp ren file??.bmp pic??.bmp The reason this doesn't work is becuase "file" and "pic" arent the same length. If you want it to work you will have to use the same length names: ren file??.bmp pict??.bmp Also this doesn't work if the names are long filenames. Not unless your dos version supports lfns. later, Lewis Townsend >