Sign in to follow this  
Followers 0
MerkurAlex

open multiple files

11 posts in this topic

mmmmmkkkk i have a program that shows fileopendialog with options of 4 now it will open the file and write the contents to a new one but im not sure how todo this with multiple files the write part anyway


[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites



Code??

#notrayicon
$top=fileopendialog("",@scriptdir,"default(*.*)",4)
if @error then 
    msgbox("","","You did not select a file to open")
    Exit
EndIf
$sop=fileopendialog("UAM converter - file to save convert to",@scriptdir,"default(*.*)",4)
if @error then
    msgbox("","","You did not select a file to save to")
    Exit
EndIf

if fileexists($sop) then filedelete($sop)
$read=fileread($top)
$opfl=fileopen($sop,1)
filewrite($opfl,$read)
fileclose($opfl)

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites

You will have to deal with it using array...

#notrayicon
$top=fileopendialog("",@scriptdir,"default(*.*)",4)
if @error then 
    msgbox("","","You did not select a file to open")
    Exit
EndIf
$sop=fileopendialog("UAM converter - file to save convert to",@scriptdir,"default(*.*)",4)
if @error then
    msgbox("","","You did not select a file to save to")
    Exit
EndIf

$read=FileRead($top)

If StringInStr($sop, "|") Then
    $FilesArr = StringSplit($sop, "|")
Else
    Dim $FilesArr[3] = [2, @WorkingDir, $sop]
EndIf

For $i = 2 To UBound($FilesArr)-1
    $opfl = FileOpen($FilesArr[1] & "\" & $FilesArr[$i], 2)
    FileWrite($opfl, $read)
    FileClose($opfl)
Next

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Couple of questions:

OK - I see that you want to open many files ... for reading ...

Do you want to write all those files into a single file? or do you want to to write each file to a different one?

If you want the files to be written each in a separate file - do you have something like a rule? like you open file1, file2 and file3 and you want them written into file_converted1, file_converted2 and file_converted3 ? or you want them written in the order returned by FileOpenDialog?

because FileOpenDialog

Return Value

Success: Returns the full path of the file(s) chosen. Results for multiple selections are "Directory|file1|file2|..."

so ... to get the filenames you will need to split the string returned using "|" and to recompose the results.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

You will have to deal with it using array...

#notrayicon
$top=fileopendialog("",@scriptdir,"default(*.*)",4)
if @error then 
    msgbox("","","You did not select a file to open")
    Exit
EndIf
$sop=fileopendialog("UAM converter - file to save convert to",@scriptdir,"default(*.*)",4)
if @error then
    msgbox("","","You did not select a file to save to")
    Exit
EndIf

$read=FileRead($top)

If StringInStr($sop, "|") Then
    $FilesArr = StringSplit($sop, "|")
Else
    Dim $FilesArr[3] = [2, @WorkingDir, $sop]
EndIf

For $i = 2 To UBound($FilesArr)-1
    $opfl = FileOpen($FilesArr[1] & "\" & $FilesArr[$i], 2)
    FileWrite($opfl, $read)
    FileClose($opfl)
Next
ok this is gonna work but in the $sop and $top are opened its limited the text in the area anyway how can i delimit it?

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites

For $i = 2 To UBound($FilesArr)-1
    $opfl = FileOpen($FilesArr[1] & "\" & $FilesArr[$i], 2)
    FileWrite($opfl, $read)
    FileWriteLine($opfl, "------- End of "&$i&" file --------")
    FileWriteLine($opfl, "")
    FileClose($opfl)
Next

this will add a line "------- End of "&$i&" file --------" and a newline at the end of each file written.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

For $i = 2 To UBound($FilesArr)-1
    $opfl = FileOpen($FilesArr[1] & "\" & $FilesArr[$i], 2)
    FileWrite($opfl, $read)
    FileWriteLine($opfl, "------- End of "&$i&" file --------")
    FileWriteLine($opfl, "")
    FileClose($opfl)
Next

this will add a line "------- End of "&$i&" file --------" and a newline at the end of each file written.

mscreators script will work i dont need that i just need to delimit text on the fileopendialogs

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites

i just need to delimit text on the fileopendialogs

Sorry but I cannot figure what do you mean ....


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Sorry but I cannot figure what do you mean ....

When it opens my Fileopendialog() function the text area you put the file paths has a character limit i need to raise that

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites

When it opens my Fileopendialog() function the text area you put the file paths has a character limit i need to raise that

I'm affraid you cannot do that since it is "nailed".

You can select as many files as you wish ... do you need to see all the names? - try clicking in the box and use the left/right arrow key to scroll the text and you will see all selected file names.

What if you select like 50 files and the whole string returned by FileOpenDialog is like 300 characters long ... where that would fit? how big that input box need to be?


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

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