Jump to content

if File exist then File2 and so on


berto
 Share

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?

Link to comment
Share on other sites

  • Developers

Something like:

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

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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!
Link to comment
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 )
Link to comment
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

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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