Jump to content

write some text to *.TXT files in Folder


Recommended Posts

hello,

what i want to do is search for *.txt files in Folder/SubFolders and write the following text at the start of file.

and if the file already have the text inside it then search for next file.

the text i want to add into files.

"Hello " & @UserName & ","
"Some information about the project."
"File information is below."
"'The name of this file is" & %filename% & " size: " & %filesize% & "-KB, -Located on " & %parent_folder%
"-This file was last Accessed in " & %DateLastAccessed% "-and created in " & %DateCreated%
"-Have a nice day ;)"
"|--****--Please add other Project info Below--****--|"

i have read about FileWrite(), FileWriteLine(), FindFileFirstFile(), etc but can't figure it out.

any example code in 'Example Scripts'? or any information how to do it?

Edited by SoftVoile
Unresolved topics:1- Please help me in Editing or replacing a page in FireFox and IE.Please have a look at them.
Link to comment
Share on other sites

hello,

what i want to do is search for *.txt files in Folder/SubFolders and write the following text at the start of file.

and if the file already have the text inside it then search for next file.

the text i want to add into files.

"Hello " & @UserName & ","
"Some information about the project."
"File information is below."
"'The name of this file is" & %filename% & " size: " & %filesize% & "-KB, -Located on " & %parent_folder%
"-This file was last Accessed in " & %DateLastAccessed% "-and created in " & %DateCreated%
"-Have a nice day ;)"
"|--****--Please add other Project info Below--****--|"

i have read about FileWrite(), FileWriteLine(), FindFileFirstFile(), etc but can't figure it out.

any example code in 'Example Scripts'? or any information how to do it?

Try this:

#include <File.au3>
$TEXT = InputBox("EXAMPLE","Write here what you want to write in files")
$PATH = FileSelectFolder("SELECT","")
$FILES = _FileListToArray($PATH,"*.TXT",1)
For $INDEX = 1 To $FILES[0]
    _FileWriteToLine($PATH & "\" & $FILES[$INDEX],1,$TEXT,0)
Next
Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

Then he would add StringInStr() to read.

how StringInStr() can read a *.txt file and match string?

StringInStr: Checks if a string contains a given substring.

also i want to search files in child Dirs/folders and it's working only for parent folder.

like in @DesktopDir & "\*\*\*\etc"

Edited by SoftVoile
Unresolved topics:1- Please help me in Editing or replacing a page in FireFox and IE.Please have a look at them.
Link to comment
Share on other sites

Search the forums for recursion and also you'll need to read the file contents to a variable then use the variable in StringInStr() to check.

Link to comment
Share on other sites

  • Moderators

could always use Run() + @COMSPEC + findstr command.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Why do I get the feeling that SoftVoile isn't learning to code? He's obviously not spending anytime trying to do this on his own. What he wants done is easily done when one wants to complete it.

SoftVoile, I would recommend that you start providing some of your own code as you seem to be trying to get everyone to do this for you, and that won't benefit you at all. Please post some sensible code as this isn't a hard task, even for someone new to coding.

Thanks,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...