Re: How can I use system cmd with variables?
- Posted by Dan Moyer <danielmoyer at p?o?igy.net> Sep 17, 2007
- 520 views
Dan Moyer wrote: > > I'm writing a small utility to rename a bunch of files in some folders, > (I need to get rid of *spaces* in the file names, & the right-click rename > won't do that), > and I thought to use the following code, but it (naturally) bombed on the > variable inside quotes...so how *would* I use a variable in this situation? > > }}} <eucode> > for n = 1 to length(newFileNames) do > system("rename folderPathName & oldFileNames[n] newFileNames[n]", 2) > end for > </eucode> {{{ > > Dan Moyer Oops, I notice now that I asked a similar question some time ago, & someone (don't remember who, sorry) provided following answer, I'll test it now.
procedure rename (sequence oldNameWithPath, sequence newNameWithoutPath) -- rename a file or directory (both names may contain spaces) system(sprintf("rename \"%s\" \"%s\"", {oldNameWithPath, newNameWithoutPath}), 2) end procedure rename (selectedFolderPathName & "\\" & cdFiles[n], newCdFileName)
Dan