Perhaps this should be under Scripts, but is there are a way to copy the selected txt files only and change the extension to csv
You can do this using xcopy in the command prompt but it takes all text files. The xcopy command I use is xcopy *.txt *.csv
Copy and Rename
Re: Copy and Rename
You are asking in the right place. There are a few ways to do what you asked, here is one:
With your txt files selected:
With your txt files selected:
Code: Select all
copyas "*.csv";
Re: Copy and Rename
OK Great thank you that was easy, how do I now make a right click shortcut menu for that?
Oh and I need it to replace the csv file if it exists already
Oh and I need it to replace the csv file if it exists already
Re: Copy and Rename
Adding commands to the shell context menu is a little trickier, while possible you would need to do it via registry editing. May I suggest an alternative of the Portable Open with Menu. https://www.xyplorer.com/tour.php?page=pom
Sample entry:
You have other options like adding it to a toolbar button, catalog item, whitespace context menu too, but the above is the easiest IMO.
edit: I see you just edited your post to say you wanted it to overwrite if file exists now, that is a bit more involved, I haven't got time to write that script myself currently am just going out, I might have later or someone else might in the meantime.
Sample entry:
Code: Select all
|"Copy as CSV"txt>::copyas "*.csv";
edit: I see you just edited your post to say you wanted it to overwrite if file exists now, that is a bit more involved, I haven't got time to write that script myself currently am just going out, I might have later or someone else might in the meantime.
Re: Copy and Rename
Thanks Jupe appreciate your help
edit: I notice copyto or moveto has an [on collision] parameter. Should I copyto a programdata temp folder first then do the copyas, then moveto existing folder than clear out the temp folder?
edit: I notice copyto or moveto has an [on collision] parameter. Should I copyto a programdata temp folder first then do the copyas, then moveto existing folder than clear out the temp folder?
Re: Copy and Rename
You could do it as you describe, there are a number of different possible solutions, here is a rough outline of another way to do it:
And if you are happy with using previously suggested POM, here is a revised entry (word wrapped):
Code: Select all
foreach($curitem, <get selecteditemspathnames |>) {
writefile(gpc($curitem, "path") . "\" . gpc($curitem, "base") . ".csv", readfile($curitem), "o");
}
Code: Select all
|"Copy as CSV"txt>::foreach($curitem, <get selecteditemspathnames |>) { writefile(gpc($curitem, "path") . "\" . gpc($curitem, "base") . ".csv", readfile($curitem), "o"); }