newroof Posted November 12, 2007 Share Posted November 12, 2007 Hi, I need to access a network folder, say \\myServer\Folder_1, and process each file one by one for each file I want to open Notepad, ctrl+v (paste) the file name, save the txt file to \\myServer\Folder_2\file_name and than close Notepad application. Please provide some sample codes. Thanks! Link to comment Share on other sites More sharing options...
weaponx Posted November 12, 2007 Share Posted November 12, 2007 Am I reading this correctly...you want to: A. Open a text file from folder1 B. Paste the filename of the opened file into itself C. Save to folder2 Link to comment Share on other sites More sharing options...
_Kurt Posted November 12, 2007 Share Posted November 12, 2007 He wants to: 1) find all files in \\server\folder\ 2) Write a new file in \\server\folder2\file.txt 3) For each file found in \\server\folder\, write it's path to \\server\folder2\file.txt Check out: _FileListToArray For..Next loops FileOpen FileWrite FileClose Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
newroof Posted November 12, 2007 Author Share Posted November 12, 2007 Thanks Kurt,This is exactly what I need to do.Ill try to follow your instructions I am new in this so I might need more help.Thanks again.He wants to:1) find all files in \\server\folder\2) Write a new file in \\server\folder2\file.txt3) For each file found in \\server\folder\, write it's path to \\server\folder2\file.txtCheck out:_FileListToArrayFor..Next loopsFileOpenFileWriteFileCloseKurt Link to comment Share on other sites More sharing options...
_Kurt Posted November 12, 2007 Share Posted November 12, 2007 (edited) It's quite simple, really, I wrote this off the top of my head, might have an error or two..#include <File.au3> $Folder1 = "\\server\folder";<-- Fill this in correctly $Folder2 = "\\server\folder2\file.txt";<-- Fill this in correctly Local $Lines = "Files Found:" & @CRLF $Files = _FileListToArray($Folder1) For $i = 0 To UBound($Files)-1 $Lines &= $i & ". " & $Files[$i] & @CRLF Next FileWrite($Folder2,$Lines)I'm worried that _FileListToArray will fail due to the fact that it's a network folder, I've never experimented with this. Tell me how it works.KurtEDIT: Minor mistake in script. Edited November 12, 2007 by _Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
newroof Posted November 12, 2007 Author Share Posted November 12, 2007 Thanks again!Ill try it.Probably I had to be more accurate from the beginning.Actually I need to point to an ftp address - ftp://ftp.mysite.com/folder1 & ftp://ftp.mysite.com/folder2.So, the working folders - folder1 & folder2 are on ftp, Notepad will run on my local machine.This will work? Link to comment Share on other sites More sharing options...
zfisherdrums Posted November 12, 2007 Share Posted November 12, 2007 (edited) Hello, newroof; An alternative approach: $dir = "\\server\folder" $textfile = "\\server\folder2\file.txt" RunWait( @ComSpec & " /c " & 'dir /b "'& $dir & '" > "' & $textfile & '"' , @ScriptDir, @SW_HIDE ) Edited November 12, 2007 by zfisherdrums Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog... Link to comment Share on other sites More sharing options...
newroof Posted November 12, 2007 Author Share Posted November 12, 2007 OK,Here is my first script it works fine except that I get 2 extra notepad documents.How Ill save the txt files and how Ill point to the ftp location (ftp://ftp.mysite.com/folder1 & ftp://ftp.mysite.com/folder2.). #include <File.au3>#Include <Array.au3>$Folder1 = "c:\working";<-- Fill this in correctly$Folder2 = "c:\out";<-- Fill this in correctlyLocal $Lines = "Files Found:" & @CRLF$Files = _FileListToArray($Folder1)For $i = 0 To UBound($Files)-1 Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send($Files[$i]) FileWrite($Folder2,$Files[$i])Next Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now