Jump to content
Babu16

Creating a folder with Date and time and need to save a file in created directory

Recommended Posts

Babu16

Hi All,

I've created a folder which has Date time appended (For example - Folder Name 'xxxx-20180202') , i will then open a created folder and Save file, but i'm unable to open a created file with date and time, Please find the following code and request you to help me to fix this.

$sFilepath ="C:\projects"

$sFilepath1 = $DirCreate($sFilepath &@YEAR &@MON &@MDAY&"-"&@HOUR &@MIN &@SEC) -; Appending time stamp to the folder

;Capture snap shot and save image file in the created folder

_ScreenCapture_Capture($sFilepath1 & "\Image01.jpg")

ShellExecute($sFilepath1 & "\Image01.jpg")

Since $sFilepath1 returning1, i'm unable to open a created file.

Share this post


Link to post
Share on other sites
Babu16

Sorry, that's Typo mistake, corrected

$sFilepath1 = DirCreate($sFilepath &@YEAR &@MON &@MDAY&"-"&@HOUR &@MIN &@SEC)

Share this post


Link to post
Share on other sites
Jos

Ok, so what i the problem with constructing a filename in the same way you construct the directory?
What have you tried that isn't working?

Jos


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

Share this post


Link to post
Share on other sites
abdulrahmanok

sure that's will not working because  $sFilepath1 will return 1

maybe this will work:

#include <ScreenCapture.au3>
$sFilepath ="C:\projects"

$sFilepath1 = DirCreate($sFilepath &@YEAR &@MON &@MDAY&"-"&@HOUR &@MIN &@SEC)

ConsoleWrite($sFilepath1)
ConsoleWrite(@CRLF&$sFilepath&@YEAR &@MON &@MDAY&"-"&@HOUR &@MIN &@SEC & "\Image01.jpg")

_ScreenCapture_Capture($sFilepath &@YEAR &@MON &@MDAY&"-"&@HOUR &@MIN &@SEC & "\Image01.jpg")

ShellExecute($sFilepath &@YEAR &@MON &@MDAY&"-"&@HOUR &@MIN &@SEC & "\Image01.jpg")

 

Edited by abdulrahmanok
  • Like 1

Share this post


Link to post
Share on other sites
Babu16

Since this  '$sFilepath1' is returning 1, whenever i execute this command ' ShellExecute($sFilepath1 & "\Image01.jpg") ' to save the captured file, i'm getting the error message as Windows can't open a file '1\image01'.

Share this post


Link to post
Share on other sites
abdulrahmanok
1 minute ago, Babu16 said:

Since this  '$sFilepath1' is returning 1, whenever i execute this command ' ShellExecute($sFilepath1 & "\Image01.jpg") ' to save the captured file, i'm getting the error message as Windows can't open a file '1\image01'.

I edited my previous code try it 

Share this post


Link to post
Share on other sites
Jos
5 minutes ago, Babu16 said:

Since this  '$sFilepath1' is returning 1, whenever i execute this command ' ShellExecute($sFilepath1 & "\Image01.jpg") ' to save the captured file, i'm getting the error message as Windows can't open a file '1\image01'.

Why are you expecting DirCreate() to return the full path? It doesn't, but rather a 1 when it was successful and else a 0!
Helpfile is your friend!

Jos

Edited by Jos

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

Share this post


Link to post
Share on other sites
Babu16

Yes, This code is working fine, thank you so much:-)

  • Like 1

Share this post


Link to post
Share on other sites
Subz

You should probably declare the name Directory and Filename otherwise you may find that it will fail since your using @Sec also not sure if you wanted to create multiple folders (since @Sec would create a new directory each time) you could use something like: C:\Projects\YYYYMMDD\HHMMSS_Image.jpg

#include <ScreenCapture.au3>

Local $sDirPath ="C:\Projects\" & @YEAR & @MON & @MDAY
    DirCreate($sDirPath)

Local $sFilepath = $sDirPath & "\" & @HOUR & @MIN & @SEC & "_Image.jpg"
_ScreenCapture_Capture($sFilepath)
ShellExecute($sFilepath)

 

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

×