I have written a VBScript that helps me organise my desktop every time it gets messy.
It works fine it moves my files and shortcuts based on the extension and the name of the app. However, I have a few app shortcut links that just won't move. in fact the vbs script will not even see them with this basic script
Set FSO = CreateObject("Scripting.FileSystemObject")
dir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
Set folder = FSO.GetFolder(dir)
Set files = folder.Files
For Each file in files
MsgBox file.Name
Next
The files in question are all shortcuts they are iTunes, VLC, Google Chrome and WinRar.
Is there anything I can check to see why vbs won't even see these files?
What You can see on your desktop is hybrid view of two folders:
C:\Users\YourUsername\Desktop
C:\Users\Public\Desktop
Where the Public one is usually a place, where shortcuts are being created during app install, so all users do have them. In your script You are only looking for files in the YourUserName\Desktop, that's why the script does not see those shortcuts.
Related
I want to set the message signature automatically each time Outlook starts. Unfortunately, the classic approach using Application_Startup() doesn't work for this. It seems that the objWord.EmailOptions.EmailSignature object is not yet available at this stage of application startup.
Is there a way to execute the script, after Outlook finishes startup?
Private Sub Application_Startup()
Set objWord = CreateObject("Word.Application")
Set objSignatureObjects = objWord.EmailOptions.EmailSignature
objSignatureObjects.NewMessageSignature = "Internal"
objSignatureObjects.ReplyMessageSignature = "Internal"
End Sub
The signatures are being kept as separate files in the Signatures folder. You can find this folder in the following locations:
Windows XP
C:\Documents and Settings\%username%\Application Data\Microsoft\Signatures
Windows Vista, Windows 7, Windows 8 and Windows 10
C:\Users\%username%\AppData\Roaming\Microsoft\Signatures
To see this folder you must have View hidden files and folders enabled or you can simply copy and paste the above paths in the address bar in Explorer to directly open the folder.
At any point in time, you may go there and edit them - deleting, adding, changing and etc.
I have recently started a little project of mine using languages such as Python or AppleScript to manipulate files and other things on a Mac. I am making multiple different programs that do these things.
Recently I began to write a program that changes the desktop background to a file on the USB stick that the program is located on. It is intended to work across different computers, so I have to keep it on the USB stick.
The issue is that when I run the program from my computer, the AppleScript seems to not be able to find the files on the USB. I am also not sure whether or not I will need to change the code when I move the program onto the USB.
The program works fine when I use files on the computer itself, but it seems to come up with an error every time it tries to retrieve an image from the USB.
Here is the appropriated code.
set Username to system attribute "USER"
set Photo to (random number from 1 to 5) as text
tell application "Finder"
make new folder at desktop with properties {name:"DesktopFolder"}
move entire contents of folder "USB/Photos/" to folder "Users/" & Username & "/Desktop/DesktopFolder/"
set desktop picture to POSIX file "/Users/" & Username & "/Desktop/DesktopFolder/Image" & Photo & ".png"
end tell
Of this, the line move entire contents of folder "USB/Photos/" to folder "Users/" & Username & "/Desktop/DesktopFolder/" is the one producing the following error Finder got an error: Can’t get folder "USB/Photos/".
What I would like to happen is that the images from the USB are copied into the new folder on the desktop, and then a random photo from this folder is chosen as the new desktop background.
Any help would be appreciated. Thanks!
The main issue is that Finder doesn't understand posix paths (i.e. slash notation); it operates using HFS paths, which uses colons in place of slashes, and substitutes in the disk name at the beginning of the file path.
So, the equivalent HFS path that points to the same location as the posix path
/Users/{{user}}/Desktop/DesktopFolder/Image4.png
is written as
Macintosh HD:{{user}}:Desktop:DesktopFolder:Image4.png
Therefore, to point to a folder on your USB drive named "USB", you would write:
USB:Photos:
Here's a modified and corrected/improved edit of your script:
set n to (random number from 1 to 5) as text
tell application "Finder"
set F to make new folder at desktop with properties {name:"DesktopFolder"}
move every item of folder "USB:Photos:" to F
set desktop picture to the file ("Image" & n & ".png") in F
end tell
I've done away with a lot of your path references that were expressed explicitly as broken string fragments, and instead set a variable to store a reference to the location of the folder you make on your desktop. That way, you can use the variable reference to target that folder for moving and selecting files.
I need to access folder on a SharePoint using VBA however the SharePoint requires Windows credentials and I do not want to map to a network drive.
When I run the code initially I get a 'path not found' error. If I open the SharePoint location in Windows Explorer it asks for my login, then when I go back to VBA the code works. I don't want to have to paste the file location into Windows Explorer every time I run it.
The code looks something like this:
Set FSO = CreateObject("scripting.FileSystemObject")
Set myFolder = FSO.GetFolder("\\this.location\foo\bar")
Is there any way to make VBA realise the path does actually exist and to prompt for the user's credentials?
Thanks.
My firm presents seminars. Each seminar runs for three days, and each contains multiple PowerPoint presentations for each day.
Our presenters have minimal technical expertise. When they’re presenting, they use a very basic remote that can forward and advance slides or switch to a black screen. That’s it.
When they get to the end of the first PowerPoint presentation, they do not want to have to walk over to the laptop, close the show, and open the next one. This needs to happen seamlessly. And for many years, it has. Older versions of PowerPoint had an option called “Package for CD” which would bundle all of the presentations into a single folder (along with any embedded audio and video files – there are lots of those). The folder would also contain an EXE of PowerPoint Viewer, and a .BAT file containing the file names of all of the shows. So all we’d have to do is run the BAT file, and each PPT file would play sequentially.
However PPT 2010 no longer bundles multiple files together. I tried to come up with a BAT file that calls for the PPT exe to run, and then lists each file, with a command line switch to run in slideshow mode. And it works… some of the time. And then some of the time it comes with a “can’t read file” error.
In a nutshell – we need a way to run a series of PPT files in slideshow mode, so that one file opens and then at the end of the file it opens the next one, without needing to press any buttons or touch the laptop.
This is the text of the BAT file I created that works intermittently:
"C:\Program Files (x86)\Microsoft Office\Office14\POWERPNT.EXE" /S 00Intro.pptx 01Legal.pptx 02pers.pptx
Any help would be appreciated.
When they get to the end of the first PowerPoint presentation, they do
not want to have to walk over to the laptop, close the show, and open
the next one. This needs to happen seamlessly.
SlideDog (http://slidedog.com) does exactly this.
You add Powerpoints to a playlist
SlideDog loads them up
SlideDog will seamlessly switch to the next PPT in line when on the last slide of the current PPT and you click next on your remote.
SlideDog currently supports Office 2010 PowerPoint and PowerPoint Viewer 2010
Disclaimer: I am one of the creators of SlideDog.
I haven't tested this. I assume that the ppt thingy ignores your 2nd and 3rd param. The docs didn't say anything about processing more than one file on the arg list.
Try this:
START /WAIT POWERPNT.EXE" /S 00Intro.pptx
START /WAIT POWERPNT.EXE" /S 01Legal.pptx
(use the relevant SET PATH=%PATH%;c:/prog .... or full path names as appropriate)
The user will have to close powerpoint before the batch file will open the next.
Slick way of getting all presentations into one presentation with individual templates:
Under New Slides, click reuse slides, choose the presentation.
To keep formatting:
Create new master slider anywhere on presentation.
Save the design template of the presentation you want to transfer slides from.
Highlight transferred slides and go to design - browse for saved design template.
Happy to answer any questions.
Do not put your code to BAT file, but to shortcut:
"C:\Program Files (x86)\Microsoft Office\Office14\POWERPNT.EXE" /S " ¤full path to file¤\00Intro.pptx" "¤full path to file¤\01Legal.pptx" "¤full path to file¤\02pers.pptx"
Or create Task for Task Scheduler (if you want run it in automatic mode:
Run: "C:\Program Files (x86)\Microsoft Office\Office14\POWERPNT.EXE"
Parameters: /S " ¤full path to file¤\00Intro.pptx" "¤full path to file¤\01Legal.pptx" "¤full path to file¤\02pers.pptx"
Both cases were succesfully tested under Win 8.1 / Office 2010
In my case:
"C:\Program Files (x86)\Microsoft Office\Office14\POWERPNT.EXE" /S "D:\Publications\CAD.pptx" "D:\Publications\showmustgoon.pptx"
I need to rename image files sequentially as they are added to a folder. ie. image-0001.jpg and image-0002.jpg are in a folder I add test.jpg and it is renamed image-0003.jpg. I have tried automators rename function but it will start over with image-0001.jpg each time a new file is added instead of continuing the sequence.
Any help is greatly appreciated.
You could make this easy on yourself by using a handy application built into the OS called "Folder Actions". Folder Actions contains one or more special handlers, formally known as folder action event handlers, that run when they are triggered by a change in the target folder. I know I'm confusing but I'll do my best.
What you are trying to accomplish requires an adding folder items to event handler. It requires one direct parameter, which can be anything you wish i.e. target_folder. The handler requires an additional parameter as well; after receiving, which should also be a variable name, i.e. these_items. I have composed a script for you that should do the trick. I have added comments that show you what I'm doing when I do it. Here it is:
on adding folder items to the target_folder after receiving these_items
tell application "Finder"
set all_images to every item of the target_folder as list
repeat with i from 1 to the count of these_items --iterates through all the items you dropped in the folder
set this_image to item i of these_items --the current image
set the name of this_image to "image" & (i + the count of all_images) as string --renames the image based on the number of images already in the folder
end repeat
end tell
end adding folder items to
YAY! The script is done! But are WE done? Not quite. We still need to attach the script to a folder (the script won't run if you try to execute it in script editor).
To do this, first save the script as a Script File in the Folder Action Scripts folder in the Scripts folder in either the local Library folder or the current user's Library folder. Create the folder yourself if it doesn't already exist. Next, launch the Folder Actions Setup application by double-clicking it in the AppleScript folder in the Applications folder. In the window that comes up, click the + button under the table on the left (click the "Enable Folder Actions" checkbox if it isn't already checked) to open a standard file browser sheet, navigate to your desired folder, and click "Open". The Choose a Script to Attach sheet automatically opens, listing all the scripts in all of the Folder Action Script folders. Choose the newly-created script, click "Attach", and BAM you are done!
To see the script in action, drag an image onto the folder. The image is instantly renamed, regardless of if the folder window is open. If you have any questions, or if the script doesn't work, just ask me. :)
well without digging through some code and handin you an answer I'll tell you want you want to do
is create a while loop that checks for the existence of image-000 & i where i is a variable of course and if it exists increment i then when the file doesn't exist rename your file.