I used "mv .ghcup/ ~/.Trash" in terminal to delete the Haskell platform. It's a pretty big file, but when I checked Trash it wasn't there. I didn't empty the Trash before checking. I also tried creating a text file and moving it to trash using the same command, and I found the text file in the trash as expected. So where did .ghcup go?
You should be able to see it in the Trash if you show hidden files.
This is because you moved a hidden file in .ghcup to the trash. The . preceding the filename marks the file as hidden on most Unix based systems such as macOS and Linux. Moving it to the Trash preserves its filename and its hidden-ness.
You can view hidden files:
In the terminal with ls -a. Navigate to your Trash folder and run the command.
Or in Finder, by opening the Trash and using the following shortcut CMD + SHIFT + .
Related
I need to rename multiple files after the folder that they are in using automator. e.g. index.html renamed to folder1.html
https://imgur.com/a/Cjgkn3V
I have about 900 folders with one file in them each all named index.html.
This is straight forward as using Terminal:
Open the Terminal app
type in "cd " (note the space) and then drag the folder containing all the folders on to the terminal window. Then press return.
Paste this in the terminal window and press enter:
for f in `ls -1`; do
if [[ -f $f/$index.html ]]; then
cp $f/index.html $f/$f.html;
fi;
done
Note that I am using the cp command here so it copies the index.html file instead of moving it. Just incase... :)
You can add this to a 'Run Shell Script' action in Automator. Just need to make sure your automator script is saved in the folder with all the sub folders.
I'm an applescript noob. So I don't know anything about this type of coding.
I want to make a script for a watch folder. I work with an image program that processes images. The process takes a second to create the jpg. So the folder has to wait for a few seconds to move the image to another file.
So this is what I'm looking for: Empty folder - jpg in the folder - wait 2 sec - move jpg to another folder - empty folder.
Thank you!
This AppleScript will accomplish what you asked. By the very nature of AppleScript, reading it should be very self explanatory as to what each line does:
on adding folder items to ThisFolder after receiving SomeFiles
set ThatFolder to POSIX file "/path/to/new/folder"
delay 2
repeat with TheFile in SomeFiles
tell application "Finder" to ¬
if name extension of (TheFile as alias) is in {"JPG", "JPEG"} then ¬
move TheFile to ThatFolder
end repeat
end adding folder items to
This is designed to run as a folder action, which makes the folder you choose automatically monitored by MacOS so that, whenever it detects a change to that folder, it executes the script attached to it. In this instance—as you can infer from the first line of the script—this will automatically run each time a file is added to the folder in question.
To set up a folder action:
Copy the AppleScript above into Script Editor. Edit the second line to replace "/path/to/new/folder" with the path to the new folder into which you want your jpegs to be moved (keep the quotes). I wouldn't bother trying to run the script from inside the editor—it won't work. The path you type out must be in full, i.e. "/Users/Richard/Pictures/Processed" and not "~/Pictures/Processed".
Save it as whatever you like. However, it must be saved in the following directory: ~/Library/Scripts/Folder Action Scripts where ~ indicates your Home folder (i.e. /Users/Richard/ or whatever it is). If the folder "Folder Action Scripts" doesn't exist, create it.
Close Script Editor. Navigate to the folder that is going to be watched, i.e. the folder that your images will be waiting initially. Now navigate one level up, into the directory containing said folder.
Right-click on the folder and hover over the Services menu item at the bottom. Then select Folder Actions Setup...
Enable folder actions by checking the box at the top. If you folder doesn't already appear in the left-hand list, you can add it. Then, in the right-hand list, click the '+' at the bottom and the script you just saved should be one of many in the list of scripts that pop up. Select it and add it.
Make sure the check boxes next to your watched folder and your chosen script are both checked, and you're done.
Now, whenever the folder receives any files whatsoever, that script is executed. The script will move any files with extensions .jpg or .jpeg into your new folder. Just make sure the new folder already exists (I didn't incorporate a line to create it if it doesn't; the script will just throw an error and your image won't be moved).
Here is a little sample script which you could save on your Desktop as monitor:
#!/bin/bash
# Source directory to watch and destination directory to copy to
SRC="$HOME/Desktop/source"
DST="$HOME/Desktop/dest"
# Create directories if not existent
mkdir -p "$SRC" "$DST"
while : ; do
find "$SRC" -type f -iname "*.jpg" -Btime +2s -exec mv {} "$DST" \;
sleep 5
done
It basically watches a directory called Desktop/source and looks for any files in there whose name ends in "JPG" and which have not been modified in the last 2 seconds. If it finds any, it then moves them to directory called Desktop/dest and sleeps for 5 seconds before checking again.
You would need to start Terminal and make the script executable by typing:
chmod +x $HOME/Desktop/monitor
Then, whenever you want it running, you just double-click on the icon of monitor on your Desktop.
I need to create a script to move all the files with certain extension from root of USB1 to specificFolder.
So far I have created a move.command file with this code
#!/bin/bash
mv /VOLUMES/USB1/*.dat /VOLUMES/USB1/specificFolder
and I am setting x bit on the file to make it executable with
chmod +x move.command
When I double click the file to launch, terminal opens up and this message is displayed
/Volumes/USB1/move.command ; exit;
logout
[Process completed]
But files are not moved over.
What am I missing?
In case somebody needs this: I solved the problem by using .sh file instead of .command file and just using this piece of code in the file
mv /VOLUMES/USB1/*.dat /VOLUMES/USB1/specificFolder
First line with /bin/bash was not needed.
Also note that the file extension is case sensitive, this command only moved .dat files and not .DAT files.
I've been trying for literally hours to set a global alias that I can use when I open Git bash on my Windows machine to cd to a specific location.
I want to be able to simply type the alias to get to the location. I've tried every which way. The attempt that got me closest was based on this: https://superuser.com/questions/602872/how-do-i-modify-my-git-bash-profile-in-windows
...but it seems that to get it to work upon relaunching of bash, I have to use source .bashrc, which I don't want to do. Help appreciated.
I just jury rigged a solution with a simple shell script that acts like a global alias. If someone has a better solution, please do tell.
Opened text editor and wrote the following two lines:
#!/bin/bash
cd blah/blep/directory_of_choice
Saved it as a text file with a descriptive name (like dirjump) somewhere and copied it.
In file explorer, navigated to the bin folder in the MinGW64 installation, e.g. "C:\Program Files\Git\mingw64\bin"
Pasted the file into this bin folder.
While viewing the contents of the bin folder referenced above in Windows file explorer, from the menu bar selected "view > options", which opened the "folder options" dialog. Selected the "view" tab here and unchecked "Hide extensions for known file types" and clicked ok.
Deleted the ".txt" extension from the file copied into the bin folder.
To call this shell script that has the same result as a global alias, typed the following in Git bash:
. dirjump (the space between the dot and the dirjump MUST be included)
I drag a lot of graphic files from Finder directly into InDesign and Photoshop. I use a vey simple bash script to quickly open the directory containing the file.
cd "/Volumes/Server/Resources/stock1/"
open .
The script opens the correct directory, but I would like to know how to get it to also go to a specified file (e.g., image.eps) and highlight/select it.
The directories I work with contain hundreds of files and have hard-to-look-through names. This would be a huge time-saver.
Thanks so much for any help. I'm using Mac OSX 10.9.5.
Use the -R (aka --reveal) option to select a single file:
open -R "/Volumes/Server/Resources/stock1/image.eps"
Something like,
open -R "/Volumes/Server/Resources/stock1/"*.eps
will not select all eps files in the folder, but instead will select each one successively, so that the end result is only the last file is selected.
#chepner's answer (-R option) is great if you want to highlight just one file. If you want to select multiple files, you may want to use Apple Script like this:
osascript -e 'tell application "Finder" to select files in folder "stock1" of folder "PHOTOS and IMAGES" of disk "Server" whose name ends with ".eps"'