Selected Files (3)
Menu Selection Send To ----
Result, Program will run for how many files are selected for this example it is 3
I have made an addition to windows registry and made a right click menu option for files. I attached a program to the option that will attach the file to an email and send me the file. When I select multiple files it will create multiple emails. What I want is for all the files to attach to a single email.
What I've tried:
1. I have tried a for loop in python script for sys.argv[n] / Didn't work because the program will run for each individual file selected
The issue is with Windows Explorer. You need to tell it you can handle multiple names. Have you registered your handler with an "open" verb? If you register it with the "OpenWithList" verb, then Explorer should send the whole list to one executable. I'm looking up the exact setting now.
Yes, HKEY_CURRENT_USER\Software\Classes\.mkv\OpenWithList\xxx.py.
Create a batch file.
insert #echo off cls command_path/command.exe %* into the batch file
Go to command location in windows registry and change the default value to the newly created batch file.
Continue if you don't want the command.exe location to be a part of the files sent
Create an array named files. ex. files = []
create a for loop to append to files ex. for i in sys.argv: if i != sys.argv[0]: files.append(i)
The files value will be inserted accordingly to the part of the api structure that handles attachments. Make sure to put it in as *files if you're not putting it into a list then files will work just fine.
(For those who are not in the know. The * is a spread operator. More examples on spread operators can be found easily by looking up spread operator.)
Related
I am relatively new to web development and very new to using Web2py. The application I am currently working on is intended to take in a CSV upload from a user, then generate a PDF file based on the contents of the CSV, then allow the user to download that PDF. As part of this process I need to generate and access several intermediate files that are specific to each individual user (these files would be images, other pdfs, and some text files). I don't need to store these files in a database since they can be deleted after the session ends, but I am not sure the best way or place to store these files and keep them separate based on each session. I thought that maybe the subfolders in the sessions folder would make sense, but I do not know how to dynamically get the path to the correct folder for the current session. Any suggestions pointing me in the right direction are appreciated!
I was having this error "TypeError: expected string or Unicode object, NoneType found" and I had to store just a link in the session to the uploaded document in the db or maybe the upload folder in your case. I would store it to upload to proceed normally, and then clear out the values and the file if not 'approved'?
If the information is not confidential in similar circumstances, I directly write the temporary files under /tmp.
I just need to refresh a folder.
A hypothetical ideal example would be:
from aModule import refreshdir # fake
refreshdir("C:\path\to\directory")
Context:
I am using Autodesk Desktop Connector, a service that sync data on the cloud with local folders. To avoid expending resources, this tool just checks for new updates when the user opens the file or refresh the directory (so manually). However, in order to automate some operations, I need to refresh the directory with Python. There is no API for this tool.
Thanks in advance! =)
Edit:
New files can be added in the cloud. That's why it is important to refresh the folder. Example:
Before refreshing:
enter image description here
After refreshing:
enter image description here
os.listdir cannot catch those highlited files before refreshing.
Refreshing a directory is not an operating system operation, but a function of the filesystem browser / explorer. A refresh is essentially just reading in the directory contents anew.
Most likely that Adobe tool is hooking into the filesystem functions that do this enumeration of a directory's contents. If this is the case, then the task should be as simple as
import os
os.listdir("C:/path/to/directory")
Keep in mind that backslashes (\) in standard string literals start an escape sequence, i.e. if you wanted to put an actual backslash there, you'd have to write "\\". However Windows will happily use forward slashes as directory separator as well, so you can just use that :-)
To solve this problem I created a script in Python using the pywinauto library to do a manually task that clicks on the file and then clicks on the Sync option.
In this case you'll need to know the name of the files you want to sync. The code was made to AutoCAD Plant 3D project, you'll need to change the path to your files.
from pywinauto import Application
raiz = "C:\\Users\\YOUR_USERNAME\\ACCDocs\\ORGANIZATION_NAME\\PROJECT_NAME\\Project Files\\PLANT3D_PROJ_NAME\\Plant 3D Models"
Application().start('explorer.exe ' + raiz, timeout=10)
explorer = Application(backend='uia').connect(path='explorer.exe', title="Plant 3D Models")
#Plant3DModels is a variable automatically created with the title of the windows opened
explorer.Plant3DModels.set_focus()
# 'Infra-Geral.dwg' is the name of the file that I will Sync
file = explorer.Plant3DModels.ItemsView.get_item('Infra-Geral.dwg')
file.right_click_input()
explorer.ContextMenu.Sync.invoke()
I made a program using tkinter (GUI module). basically it is a banking system that stores data in text files. I found that a desktop.ini file was created in that folder. why so? Is it harmful if I delete the file?
[.ShellClassInfo]
IconResource=C:\WINDOWS\System32\SHELL32.dll,27
[ViewState]
Mode=
Vid=
FolderType=Generic
👆 this is what is there in that file.
it's a windows config file and is not harmful or a vulnerability
According to https://answers.microsoft.com/en-us/windows/forum/all/there-are-these-random-desktopini-files-appearing/5bb923f5-6b06-4e07-a79e-a16c8bfc844a
You should not delete them.
A Desktop.ini file is a file that determines the way a folder is displayed by Windows. These files can be found in any folder, anywhere on your computer, as long as that folder has a custom appearance set for it. Desktop.ini files control things like the icon used for that folder and its localized name.
Deleting them will always regenerate them anyway. If you don't want to see them, turn off show hidden files and folders in File Explorer > View tab > uncheck hidden files.
The script needs to read from a .txt file with a list of items and based off that list, it creates a directory for each item. So just a simple with open() statement and then os.mkdir()..
The client will add account names to the txt file when they get new accounts, the program will create new directories for those new accounts. Files that are then placed in each directory for those accounts will get pandas stuff done to them and moved to an archive folder along with logging the events.
Since the program will be used by non-programmers, I'm using Pyinstaller.
When I go through the process, including the --add-file attribute, run the program, it says the txt file doesn't exist. I think I have an idea how to fix that but when I got the os.mkdir and with open statements to work by separating them out, it created them in the home folder and not the program folder. Path issue? And I only see documentation on how to include data files but not how to include changeable files.
Alright, I have two folders that need to be in sync, but certain files need to be ignored before the first upload.
To make sense of what I mean lets say for example I have a folder called src and another folder called dest.
src contains settings.properties, some python code, and a template properties file.
dest contains the same settings.properties, same python code but the template properties file is populate during the sync process (done by a script that wraps the protocol)
Now, if I decide to modify the python code in dest, the python code should be updated in src folder, but the new template.properties which is populated should be ignored.
I tried using excludes and includes but I read that you can't use both because "includes takes precedence"
Using Windows, and I am currently using a python script that formats the paths to the default "/cygdrive/C/" then I populate the properties file, then I run rsync