AutoHotkey Community

It is currently May 27th, 2012, 1:01 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: January 3rd, 2010, 1:05 am 
Offline

Joined: August 15th, 2009, 7:20 am
Posts: 308
Hello,

I've cobbled together a script that lists the files in a chosen directory:
Code:
FileSelectFolder, FolderName, , 3, Folder Contents - Choose a folder
if FolderName =
   MsgBox, You didn't choose a folder.
else
  {
  SplitPath,A_LoopFileLongPath,FileNameNoExt ;Extract Directory,filename, and extension
 
 
    WordList =
    Loop, %FolderName%\*.*, 0, 0
        WordList = %WordList%%A_LoopFileName%`n

    SplitPath, FolderName, OutFileName
    FileName = C:\Documents and Settings\All Users\Desktop\%OutFileName%.txt

    FileAppend, %WordList%, %FileName%
   
   
   FileRead, Contents, %FileName%
   if not ErrorLevel  ; Successfully loaded.
{
    Sort, Contents
    FileDelete, %FileName%
    FileAppend, %Contents%, %FileName%
    Contents =  ; Free the memory.
}
   
   
    run, Notepad %FileName%
  }

What I want to do is strip out the extension and then split each line into individual words. I looked at StringTrimRight but couldn't work out how to use it on each line. I'm sure it's a basic loop but I'm stuck. Help appreciated.

Thanks,

GP


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 3rd, 2010, 3:56 am 
Offline

Joined: August 15th, 2009, 7:20 am
Posts: 308
Hello again,

I've figured out how to strip out the extension:
Code:
FileSelectFolder, FolderName, , 3, Folder Contents - Choose a folder
if FolderName =
   MsgBox, You didn't choose a folder.
else
  {
 
    Loop, %FolderName%\*.*, 0, 0
        WordList = %WordList%%A_LoopFileName%`n

    SplitPath, FolderName, OutFileName
    FileName = C:\Documents and Settings\All Users\Desktop\%OutFileName%.txt
   
   
    FileAppend, %WordList%, %FileName%.new
   
   Loop, Read, %FileName%.new, %FileName%.tem
  {
  StringTrimRight, trimExt, A_LoopReadLine, 4
      FileAppend, %trimExt%`n
  }
   FileMove, %FileName%.tem, %FileName%, 1
   
         
   FileRead, Contents, %FileName%
   if not ErrorLevel  ; Successfully loaded.
{
    Sort, Contents
    FileDelete, %FileName%
    FileAppend, %Contents%, %FileName%
    Contents =  ; Free the memory.
}
   
   
    run, Notepad %FileName%
  }

No I want to break up each line into individual words and create a file with one word on each line. I've looked at Stringsplit but teh example with the messge box doesn't make much sense to me. How do I get every single word?

Thanks,

GP


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 3rd, 2010, 5:47 am 
Offline

Joined: August 15th, 2009, 7:20 am
Posts: 308
I found a solution without using SplitString - just replacing the spaces with new lines was sufficient.

GW


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Leef_me, WillTroll, Yahoo [Bot] and 30 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group