I have bunch of folders in the current directory. Each folder will have bunch of files ( no sub folders though )
First I need to replace all the spaces in the folder names with an underscore then I need to crate 2 txt files.
All the file names in folder X should go into first text file and files in all other folders will to into second file.
folder 1
folder 2
folder 3
folder X
folder 4
Can this be done using script ? Thanks in advance.
Help for writing list of the files to 2 files
-
- XY Blog Master
- Posts: 5824
- Joined: 02 Jan 2006 19:34
- Location: So. Chatham MA/Clearwater FL
- Contact:
Re: Help for writing list of the files to 2 files
Hi and welcome to the XY forums!
I'm not a script'r but can tell you that this particular function can easily be done via File>Rename Special>Spaces to _lazydba wrote:First I need to replace all the spaces in the folder names with an underscore
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.
Re: Help for writing list of the files to 2 files
Hi and welcome lazydba.
Please see if you can do something with this script.
See the wiki how to use an script: http://88.191.26.34/XYwiki/index.php/Scripting
Note:
"sel +1;" didn't selected just the next item anymore for me (but the second in list), i think it has done in past?
So i used "sel "[$ActualFolder]";" first here.
Please see if you can do something with this script.
See the wiki how to use an script: http://88.191.26.34/XYwiki/index.php/Scripting
Code: Select all
"Rename Special: Spaces to _"
//Just use the build-in command: "File>Rename Special>Spaces to _"
//Select items to rename first on your own.
#129;
"List files to text file"
//Select the first folder in question on your own first.
$StartFolder = "<curpath>";
$XFolder ="";
$OtherFolders = "";
while(1){
$IsFolder = report ("{Dir Yes|No|Drive}",1);
IF ("$IsFolder" == "Yes"){
$ActualFolder = "<curname>";
$curfolder = "<curitem>";
goto $curfolder;
IF ("<curname>"=="X"){
$XFolder = $XFolder$curfolder<crlf> . Report("{Name}<crlf>") . <crlf>;
}else{
$OtherFolders = $OtherFolders$curfolder<crlf> . Report("{Name}<crlf>") . <crlf>;
}
goto $StartFolder;
sel "[$ActualFolder]";
sel +1;
}else{
msg "No more folders. See output files.";
//just sgow an messages box:
//If (strlen($XFolder) > 0) {text $XFolder;}
//If (strlen($OtherFolders) > 0) {text $OtherFolders;}
//write info to file:
//writefile(filename, data, [on_exist], [mode])
If (strlen($XFolder) > 0) {writefile("C:\Temp\XFolders.txt", $XFolders);}
If (strlen($OtherFolders) > 0) {writefile("C:\Temp\OtherFolders.txt", $OtherFolders);}
break;
}
}
Note:
"sel +1;" didn't selected just the next item anymore for me (but the second in list), i think it has done in past?
So i used "sel "[$ActualFolder]";" first here.
Re: Help for writing list of the files to 2 files
Thanks so much. It worked like a charm.
-
- Site Admin
- Posts: 60635
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Help for writing list of the files to 2 files
@Stefan: I don't think "sel +1;" changed its behavior.
FAQ | XY News RSS | XY Twitter
Re: Help for writing list of the files to 2 files
Right now it is forcing me to select the first folder in the list. Is there a way to avoid that. No beggie, sometimes I might forget to select it. thx
Re: Help for writing list of the files to 2 files
I don't understand. What is the part you want?lazydba wrote:Right now it is forcing me to select the first folder in the list. Is there a way to avoid that. No beggie, sometimes I might forget to select it. thx
Should the script select the first folder for you?
Then just write an
sel 1;
right under
//Select the first folder in question on your own first.
Re: Help for writing list of the files to 2 files
Yes. That is what I wanted. Worked perfect. Thanks so much.