Jump to content
Sign in to follow this  
newroof

Process all files from a network folder

Recommended Posts

newroof

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!

Share this post


Link to post
Share on other sites
weaponx

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

Share this post


Link to post
Share on other sites
_Kurt

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..

Share this post


Link to post
Share on other sites
newroof

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.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

Share this post


Link to post
Share on other sites
_Kurt

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.

Kurt

EDIT: Minor mistake in script.

Edited by _Kurt

Awaiting Diablo III..

Share this post


Link to post
Share on other sites
zfisherdrums

Hello, newroof;

An alternative approach:

$dir = "\\server\folder"
$textfile = "\\server\folder2\file.txt"
RunWait( @ComSpec & " /c " & 'dir /b "'& $dir & '" > "' & $textfile & '"' , @ScriptDir, @SW_HIDE  )
Edited by zfisherdrums

Share this post


Link to post
Share on other sites
newroof

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 correctly

Local $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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×