Python Forum
Filename stamp script is needed
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Filename stamp script is needed
#6
(Apr-07-2021, 04:33 PM)bowlofred Wrote: Files aren't onscreen, windows are. File data may be used to draw some of the information in that window, but
that doesn't mean there's a one-to-one relationship between files and windows.

Unfortunately, GUIs aren't standardized in a cross-platform way. I don't know any way to query a window and have the controlling app respond with the filename associated with that window.

Or are you talking about a window that's part of your application?

I am talking about any text file that's open on screen in any text editor.

Here is an example inserted by a Windows text editor: 2021-04-07 - Z:\media\linux-data\google-drive\shared\linux-notes.txt

This is what I have so far.

# Description, kybd = win + INS insert current date, time and path and filename

import os, time, datetime

ts = time.time()
time_stamp = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M') + " "
# file_name = 
keyboard.send_keys(time_stamp)
# keyboard.send_keys(time_stamp + "-" + file_name)
Please note that "keyboard.send_keys" is the substitute for print()

If I knew how to access the system variables in Python, I am sure that one of them would have the active filename.
Reply


Messages In This Thread
Filename stamp script is needed - by ineuw - Apr-07-2021, 05:53 AM
RE: Filename stamp script is needed - by Larz60+ - Apr-07-2021, 09:26 AM
RE: Filename stamp script is needed - by ineuw - Apr-07-2021, 02:50 PM
RE: Filename stamp script is needed - by Larz60+ - Apr-07-2021, 04:30 PM
RE: Filename stamp script is needed - by bowlofred - Apr-07-2021, 04:33 PM
RE: Filename stamp script is needed - by ineuw - Apr-07-2021, 05:00 PM
RE: Filename stamp script is needed - by bowlofred - Apr-07-2021, 05:28 PM
RE: Filename stamp script is needed - by ineuw - Apr-09-2021, 10:37 AM
RE: Filename stamp script is needed - by ineuw - Apr-12-2021, 11:03 PM
RE: Filename stamp script is needed - by bowlofred - Apr-09-2021, 04:21 PM
RE: Filename stamp script is needed - by ineuw - Apr-24-2021, 05:50 AM
RE: Filename stamp script is needed - by ineuw - Sep-12-2023, 03:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to map by time stamp and name SriRajesh 0 1,171 Apr-09-2022, 12:49 PM
Last Post: SriRajesh
  extract zip from .msg files and saving according to date stamp of email natjo 3 2,973 Aug-13-2020, 09:35 PM
Last Post: bowlofred
  copy with new time stamp leveex 0 1,819 Mar-29-2020, 08:46 PM
Last Post: leveex
  Manipulating the filename of an output script mckinneycm 4 11,937 Jan-15-2020, 07:29 PM
Last Post: mckinneycm
  How to save latest time stamp in a file? redwood 12 7,305 Jul-11-2019, 11:03 AM
Last Post: redwood

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020