Sunday, April 20, 2014

Re: automatically editing many .tec files

Shlomi has given an all in one command which assumes a unix-like environment, but I suspect because "cmd" is mentioned that Asaf's on windows.

While I like, and use, single line do-it-all-at-once solutions, when there's a bunch of stuff one doesn't want to lose, or there's other pressures, a step by simple step approach, where one sees each step's results, can be good.

So, I'd first create a file with the list of the file names. On windows, that would be, in a command window having changed to the right directory:

dir /b *.tec > photos.bat

(from rusty windows memory, we want a single column of file names, with no spaces at the beginning of each line)
Then, open photos.bat in vim, and duplicate each name with two spaces between them:

:%s/.*/& &/

delete the first 6 characters after the spaces

:%s/ ....../ /

delete the first character before the dot at the end

:%s/.\.tec$/.tec/

change tec to jpg:

:%s/tec$/jpg/

add a rename command to the beginning of each line

:%s/^/ren /

save the file, exit vim, and run the batch file

$ photos.bat

On *n*x the first command would have "ls" instead of "dir /b", "ren" would be "mv", and the last would be

$ sh photos.bat

HTH, and regards, John Little

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: