How to flatten a directory on Mac through terminal
Recently, I was handed a project with pre-built ANT scripts that zip folders up into individual directories. The zip files in each folder needed to be uploaded to an FTP site without the folder so having to navigate into each was a bit annoying and time consuming for 40 files.
If you find yourself in need of merge or flatten a folder/directory, use this snippet to flatten everything into a single directory. If a file exists with the same name, you’ll be prompted to overwrite or leave in the existing folder.
find $PWD -mindepth 2 -type f -exec mv -i '{}' $PWD/ ';'
In my case, there was an extra file generated within each folder that was not used and I didn’t want to be prompted 40 times to overwrite so changing the -i to -n will force files to be overwritten. I’d recommend using caution with this and only use it when you know the duplicate files don’t matter.
find $PWD -mindepth 2 -type f -exec mv -n '{}' $PWD/ ';'
Cheap Macbook Pro Docking Solution for about $30
I typically prefer developing on my desktop and large dual screen monitor setup as opposed to my Macbook. Recently, I’ve gotten into more PHP development and developing on the Mac is proving to be a more enjoyable experience only because Windows is still a second class citizen for most PHP libraries/tools. I still wanted a larger screen setup, so I considered buying a docking station to hook up to a larger monitor but I soon learned they feature the ‘Mac Penalty’ in that they cost more than they should just because it’s for Apple products.
I already have two large monitors and figured my Macbook could serve as third screen. Then I did some thinking and realized I could use one of the monitors for both computers. Assuming you have two HDMI screens already hooked up to your desktop, this would save you $150+ and still allow you to be more productive.
- Get a copy of Synergy (http://symless.com/) for $10. It’s open source and can be built if you have the time, but a one time fee of $10 saves me the hassle of doing so. With this, you can share your desktop keyboard across all your computers with the one license and it’s cross platform so Linux support is included too.
- Purchase an auto HDMI switcher. I purchased the PORTTA PET0301S 3×1 Port HDMI Switch/Switcher for about $9.
- Be sure to get 2 HDMI cables if you don’t already have them on hand. I don’t like the Amazon Basic brand for these as I’ve had problems with the Mac and those cables hooking up to larger screens.
- Install Synergy on the desktop as a server. Install on the Macbook as a client and it should autoconnect.
- Plug the HDMI cable from the computer into the HDMI switcher, and plug the spare into the Macbook pro. Plug the “Out” end into the monitor.
When you plug your HDMI cable into the Macbook, the HDMI switcher will automatically switch to it and project the Macbook. Synergy will auto-connect as long as it’s running on both and you can share the mouse and keyboard between both and work seamlessly.
If you have an iPad and want to turn that into an additional screen, grab a copy of Duet Display on your desktop/Macbook and install on your iPad for $15.99, and viola, instant portable second screen!