Help with FileSelectFile to limit size file Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Help with FileSelectFile to limit size file

26 Mar 2017, 05:45

Hii,

Ive got this script which copying a selected file to some another folder,
I want to limit the choose of the file in size \ 5mb.
I mean: if I select file with size more than 5mb then I won't be able to continue.

thanks in advance!

Code: Select all

FormatTime, TimeString,, LongDate

FileSelectFile, OutputVar, s,
SplitPath, OutputVar, name
if OutputVar =
{
    MsgBox 0x180030, , file not chosen!
    return
}
else
            FileDelete, c:\%TimeString%\*.*            
    FileCreateDir, C:\%TimeString%
            FileCopy, %OutputVar%, c:\%TimeString%\, 1
    MsgBox 0x180040, , file loaded:`n "%name%"
return
User avatar
boiler
Posts: 17042
Joined: 21 Dec 2014, 02:44

Re: Help with FileSelectFile to limit size file

26 Mar 2017, 06:06

Use FileGetSize after they've selected the file, then exit or whatever depending on the result of an if statement comparing the size to 5MB.
garry
Posts: 3772
Joined: 22 Dec 2013, 12:50

Re: Help with FileSelectFile to limit size file  Topic is solved

26 Mar 2017, 06:32

short example

Code: Select all

FileSelectFile, OutputVar, s,
SplitPath, OutputVar, name
if OutputVar =
  return
{
FileGetSize,fs, %outputvar%,M
if (fs>=5)
    {
    msgbox, 262208,FileSize ,Size>= as 5 Megabytes`nSize = about > %fs% Megabytes
    exitapp
    }
else
  {
  msgbox, 262208,FileSize ,Size = about > %fs% Megabytes
  ;- continue here
  }
}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest, Bing [Bot], jdfnnl and 335 guests