Jump to content
Sign in to follow this  
berto

if File exist then File2 and so on

Recommended Posts

Hy. i have a little app that creats a file named file.abc on destop, now i want to implement some new features and i want the app to check is file.abc already exist, if yes then create file2.abc, and if file2.abc also exists the create file3.abc and so on.

Can u help me?

Share this post


Link to post
Share on other sites

Something like:

$Filename = "file.abc"
$count = 0
While FileExists($Filename)
        $count += 1
        $Filename = "file" & $count & ".abc" 
WEnd
ConsoleWrite('$Filename = ' & $Filename & @crlf )

Jos

Share this post


Link to post
Share on other sites

Lookup:

FileExists

While loops

~cdkid


AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

Im stuck, here that part of code that i have problems with

;; Save bitmap to file
#include <A3LClipboard.au3>
#include <A3LScreenCap.au3>
$check = _Clip_IsFormatAvailable($CF_BITMAP)
If $check = true Then
    $ps = _Clip_GetData($CF_BITMAP)
    _ScreenCap_SetJPGQuality(100)
    _ScreenCap_SaveImage(@DesktopDir &"\Image.jpg", $ps)
EndIf
If $check = false Then
    MsgBox (0, "Info", "Nu ai nici un screenshoot in clipboard")
    Exit
EndIf

$Filename = "Image.jpg"
$count = 0
While FileExists($Filename)
        $count += 1
        $Filename = "Image" & $count & ".jpg"
WEnd
ConsoleWrite('$Filename = ' & $Filename & @crlf )

Share this post


Link to post
Share on other sites

Im stuck, here that part of code that i have problems with

;; Save bitmap to file
#include <A3LClipboard.au3>
#include <A3LScreenCap.au3>
$check = _Clip_IsFormatAvailable($CF_BITMAP)
If $check = true Then
    $ps = _Clip_GetData($CF_BITMAP)
    _ScreenCap_SetJPGQuality(100)
    _ScreenCap_SaveImage(@DesktopDir &"\Image.jpg", $ps)
EndIf
If $check = false Then
    MsgBox (0, "Info", "Nu ai nici un screenshoot in clipboard")
    Exit
EndIf

$Filename = "Image.jpg"
$count = 0
While FileExists($Filename)
        $count += 1
        $Filename = "Image" & $count & ".jpg"
WEnd
ConsoleWrite('$Filename = ' & $Filename & @crlf )
By your code, you're wanting us to spoon feed you. Sorry, it doesn't work that way. Jos and cdkid gave you everything you require with his example. Use your brain and modify it to your specific needs.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Its important to try to understand the stuff :)

Here is where the filecheck could be implemented (Untested):

;; Save bitmap to file
#include <A3LClipboard.au3>
#include <A3LScreenCap.au3>
$check = _Clip_IsFormatAvailable ($CF_BITMAP)
If $check = True Then
    $Filename = @DesktopDir & "\Image.jpg"
    $count = 0
    While FileExists($Filename)
        $count += 1
        $Filename = @DesktopDir & "\Image" & $count & ".jpg"
    WEnd
    $ps = _Clip_GetData ($CF_BITMAP)
    _ScreenCap_SetJPGQuality (100)
    _ScreenCap_SaveImage ($Filename, $ps)
EndIf
If $check = False Then
    MsgBox(0, "Info", "Nu ai nici un screenshoot in clipboard")
    Exit
EndIf

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  

×
×
  • Create New...