Jump to content

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


Babu16
 Share

Recommended Posts

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.

Link to comment
Share on other sites

  • Developers
2 minutes ago, Babu16 said:

$DirCreate

Shouldn't that be without the $ as this is not a variable but a function?

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

  • Developers

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 etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

  • Developers
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 etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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)

 

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