Quantcast
Channel: PTC Community: Message List
Viewing all articles
Browse latest Browse all 11560

Re: How to add time stamp to a file (.jpg) with Mapkey?

$
0
0

This can be done witha  batch file that's called as part of the mapkey sequence.  It's not hard, but you'll need to know some batch file programming.

 

Here's some snippets that might help you (we have batch files that create dated folders as well as rename exported files to append the revision or a custom suffix)

 

This creates a date based folder:

 

rem ** create destination folder

date /t > fulldate.txt

for /F "tokens=2 delims= " %%i in (fulldate.txt) do set today=%%i

set today > date.txt

for /F "tokens=2 delims=/=" %%i in (date.txt) do set MONTH=%%~i

for /F "tokens=3 delims=/=" %%i in (date.txt) do set DAY=%%~i

for /F "tokens=4 delims=/=" %%i in (date.txt) do set YEAR=%%~i

SET destination_folder=%YEAR:~-2%%MONTH%%DAY%_%long_type%

md %destination_folder%

del fulldate.txt

del date.txt

 

This finds the file name of a give type of file, assuming the %type% and %long_type% variables are set earlier in the file. It also assumes that there is only one file of that type in the folder (we use a temp folder for file processing):

 

rem ** generate list of %long_type% files

dir /b *.%type% > dir.txt

 

rem ** extract the %long_type% file name

findstr ".%type%" dir.txt > %type%.txt

for /F "tokens=1 delims=. " %%i in (%type%.txt) do set FILENAME=%%~ni

del dir.txt

del %type%.txt

 

This renames a file with a suffix, again assuming the variables are set earlier in the file:

 

rem ** rename file with suffix

rename %FILENAME%.%type% %FILENAME%%suffix%.%type%

 

This is the line from one of our mapkeys that calls a batch file:

 

mapkey(continued) @SYSTEMP:\\config\\00_design_central\\export\\dcex_temp_dir;\

 

dcex_temp_dir is a batch file with a .bat extension.

 

That should get you started, but you'll need to read up on batch files to piece this into something useful for your organization.


Viewing all articles
Browse latest Browse all 11560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>