Sign in to follow this  
Followers 0
SoftVoile

write some text to *.TXT files in Folder

11 posts in this topic

#1 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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

Add FileRead() to read.

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Add FileRead() to read.

Yes but if he use fileread for have some sentences in file, how he would do ?

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Yes but if he use fileread for have some sentences in file, how he would do ?

Then he would add StringInStr() to read.

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Then he would add StringInStr() to read.

I was searching for string functions, you found it lol


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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.

Share this post


Link to post
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)

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  
Followers 0