Remove the trailing slash from a folder

Hi everyone,
My company has several remote sites that rely on documentation I write here at WHQ in order to deploy macs according to company standards. Since these documents are in constant update mode, I wrote a small droplet that I use to just drop the documentation folder on and copy it to the remote site servers overwriting any existing documentation folder.
I have the following piece of code:
if CHIError is not equal to "" then
display alert CHIError giving up after 5
else
repeat with anItem in droppedItems
if ((kind of (info for anItem)) = "Folder") then
set anItem to quoted form of POSIX path of anItem
do shell script "cp -rf " & anItem & space & "/Volumes/MacPackaging$/MacDocumentation/"
else
set anItem to quoted form of POSIX path of anItem
do shell script "cp -f " & anItem & space & "/Volumes/MacPackaging$/MacDocumentation/"
end if
end repeat
end if
The problem I am running into is that when anItem is a folder and converted to a POSIX path, it ends up with a trailing slash, causing cp -r to copy only the contents of the folder and not the folder itself... Is there a way to remove the trailing slash or another conversion method I can use to copy the entire folder?
If I take out the if statement to check for a folder and the -r flag on cp, cp errors out telling me that anItem is a directory and can't be copied, which is to be expected. Ah... how I wish bash could do droplets...

By the way, since the “info for” command is now deprecated, you could as well write your repeat block as follows:
*repeat with anItem in droppedItems*
*   if last character of (anItem as text) is ":" then*
*      set anItem to quoted form of text 1 through -2 of POSIX path of anItem*
*      do shell script "cp -rf " & anItem & space & "/Volumes/MacPackaging$/MacDocumentation/"*
   else
*      set anItem to quoted form of POSIX path of anItem*
*      do shell script "cp -f " & anItem & space & "/Volumes/MacPackaging$/MacDocumentation/"*
*   end if*
*end repeat*
On the other hand, if you would like to use pure AppleScript, you could also replace the whole repeat block with the following single line of code:
*tell application "Finder" to duplicate droppedItems to POSIX file "/Volumes/MacPackaging$/MacDocumentation/" with replacing*

Similar Messages

  • Major crawler issues - removal of trailing slashes from URLs and (seemingly) poor regex implementation

    I've been suffering from two issues when setting up a crawl of an intranet website hosted on a proprietary web CMS using SharePoint 2010 Search. The issues are:
    1: The crawler appears to remove trailing slashes from the end of URLs.
    In other words, it turns http://mysite.local/path/to/page/ into http://mysite.local/path/to/page. The CMS can cope with this as it automatically forwards requests for http://mysite.local/path/to/page to http://mysite.local/path/to/page/ -
    but every time it does this it generates a warning in the crawl - one of the "URL was permanently moved" warnings. The URL hasn't been moved, though, the crawler has just failed to record it properly. I've seen a few posts about this in various places,
    all of which seem to end without resolution, which is particularly disappointing given that URLs in this format (with a trailing slash) are pretty common. (Microsoft's own main website has a few in links on its homepage - http://www.microsoft.com/en-gb/mobile/
    for instance).
    The upshot of this is that a crawl of the site, which has about 50,000 pages, is generating upwards of 250,000 warnings in the index, all apparently for no reason other than the crawler changes the address of all the pages it crawls? Is there a fix for this?
    2: The Regex implementation for crawl rules does not allow you to escape a question mark
    ... despite what it says
    here: I've tried and tested escaping a question mark in a url pattern by surrounding it in square brackets in the regex, i.e.: [?] but regardless of doing so, any URL with a question mark in just falls right through the rule. As soon as you remove the 'escaped'
    (i.e. seemingly not actually escaped at all) question mark from the rule, and from the test URL pattern, the rule catches, so it'd definitely not escaping it properly using the square brackets. The more typical regex escape pattern (a backslash before the
    character in question) doesn't seem to work, either. Plus neither the official documentation on regex patterns I've been able to find, nor the book I've got about SP2010 search, mention escaping characters in SP2010 crawl rule regexes at all. Could it be that
    MS have released a regex implementation for matching URL patterns that doesn't account for the fact that ? is a special character in both regex and in URLs?
    Now I could just be missing something obvious and would be delighted to be made to look stupid by someone giving me an easy answer that I've missed, but after banging my head against this for a couple of days, I really am coming to the conclusion that Microsoft
    have released a regex implementation for a crawler that doesn't work with URL patterns that contain a question mark. If this is indeed the case, then that's pretty bad, isn't it? And we ought to expect a patch of some sort? I believe MS are supporting SP2010
    until 2020? (I'd imagine these issues are fixed in 2013 Search, but my client won't be upgrading to that for at least another year or two, if at all).
    Both these issues mean that the crawl of my client's website is taking much longer, and generating much more data, than necessary. (I haven't actually managed to get to the end of a full crawl yet because of it... I left one running overnight and I just
    hope it has got to the end. Plus the size of the crawl db was 11GB and counting, most of that data being pointless warnings that the crawler appeared to be generating itself because it wasn't recording URLs properly). This generation of pointless mess
    is also going to make the index MUCH harder to maintain. 
    I'm more familiar with maintaining crawls in Google systems which have much better regex implementations - indeed (again, after two days of banging my head against this) I'd almost think that the regex implementation in 2010 search crawl rules was cobbled
    together at the last minute just because the Google Search Appliance has one. If so (and if I genuinely haven't missed something obvious - which I really hope I have) I'd say it wasn't worth Microsoft bothering because the one they have released appears to
    be entirely unfit for purpose?
    I'm sure I'm not the first person to struggle with these problems and I hope there's an answer out there somewhere (that isn't just "upgrade to 2013")?
    I should also point out that my client is an organisation with over 3000 staff, so heaven knows how much they are paying MS for their Enterprise Agreement. Plus I pay MS over a grand a year in MSDN sub fees etc, so (unless I'm just being a numpty) I would
    expect a higher standard of product than the one I'm having to wrestle with at the moment.

    Hi David,
    as i know in sharepoint 2010 crawl there is a rule to include or exclude the URL that using '?' characters, if i may know have you implemented the rule?
    In the Crawl Configuration section, select one of the following options:
    Exclude all items in this path. Select this option if you want to exclude all items in the specified path from crawls. If you select this option, you can refine the exclusion by selecting the following:
    Exclude complex URLs (URLs that contain question marks (?)). Select this option if you want to exclude URLs that contain parameters that use the question mark (?) notation.
    Include all items in this path. Select this option if you want all items in the path to be crawled. If you select this option, you can further refine the inclusion by selecting any combination of the following:
    Follow links on the URL without crawling the URL itself. Select this option if you want to crawl links contained within the URL, but not the starting URL itself.
    Crawl complex URLs (URLs that contain a question mark (?)). Select this option if you want to crawl URLs that contain parameters that use the question mark (?) notation.
    Crawl SharePoint content as HTTP pages. Normally, SharePoint sites are crawled by using a special protocol. Select this option if you want SharePoint sites to be crawled as HTTP pages instead. When the content is crawled by using the HTTP
    protocol, item permissions are not stored.
    for the trailing slash issue, may i have your latest cumulative update or your sharepoint database number? as i remember there was a fix on SP1 + june update regarding trailing slash, but not quite sure if the symptoms are the same with your environment.
    Sharepoint may use sharepoint connector regarding regex, but older regex may not able to have a capability to filter out the parameters so, a modification regarding the trailing slash may happend.
    please let us know your feedback.
    Regards,
    Aries
    Microsoft Online Community Support
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • When attempting to remove the Filmconvert plugin from my machine I noticed my adobe\common\plug-ins\CS5.5\MediaCore folder had Vanished !

    When attempting to remove the Filmconvert plugin from my machine I noticed my adobe>common>plug-ins>CS5.5>MediaCore folder had vanished ! and there was also no folder for my cc version at all ? so digging deeper i noticed a large amount of my after effects plugins were installed separately in my applications folder ! I m very confused as to how this has happened and was wondering if anything like this had happened to any1 else ? and how to get everything back to normal ?
    Im now worried theres something wrong with my bios on my Mac and i don't no why my plug-ins would have vanished from where they should be installed? as they still work fine in the actual software itself.

    If you are on a Mac the Library folder is hidden. You have to jump through some hoops to get there.

  • Remove the word alias from Aliases when moving to a specific folder?

    Title says it all. I am looking for a script to add to folder actions so that when I move an alias to a certain folder it removes the word alias from the end of it.

    Hi Spectre
    try the below
    on adding folder items to this_folder after receiving (added_items)
    tell application "Finder"
    set _files to (files of this_folder whose name ends with "alias")
    repeat with _file in _files
    set _name to name of _file
    set name of _file to (characters 1 thru -6 of _name as text)
    end repeat
    end tell
    end adding folder items to
    Budgie
    Message was edited by: Budgie

  • I have converted/copied my itunes oto mp3 format to play on my PC. unfortunatly I didi not specify a different folder fro the mp3's. I therefore have itunes side by side with my mp3's all in the same folder. How can I remove the mp3's into another folder.

    I have converted my itunes on my imac to mp3 format so i could play them on my pc. unfortunatly  i did not specify a seperate folder for the mp3's to be sent to once converted.
    i now have itunes and mp3's side by side in the itunes media folder. this has the effect of doubling my library.
    how can i get rid of the mp3's from this folder en mass, other than erasing them one by one, there are 7000!!!

    Click on 'Music' in the iTunes sidebar. Look to see whether you have a 'Kind' column:
    If you haven't, choose 'View Options' from the 'View' menu and check 'Kind':
    Now go to the Music list again and click on the label of the 'Kind' column. This will group all your AACs and MP3s together. Locate the MP3s: click on the top one. Hold the shift key and click on the bottom one to select them all. If you want to save them drag them to a folder on your Desktop. Then hit 'Delete'. IMPORTANT: when promted, choose to have them moved to the Trash, otherwise they will be removed from the list but kept in the actual library.

  • How Can I Remove the Finder Icon From the Dock?

    Hi! Can someone tell me how to remove the Finder icon from the dock? I don't even care if Finder quits. I just want it removed from the dock. I really don't care if I can't get to my files. Please help.

    Start by going to your core services, (/system/library/coreservices). You can do this by pressing Shift+Cmd+G and then paste (/system/library/coreservices), without parentheses.
    After doing this, find Dock.app, right click, show package contents. This doesn't contain the icons on your dock, just finder and trash.
    After that, move all finder services to the desktop, and then erase them from the core services folder. At this point it will prompt you to put in your password, do so.
    Next you'll want to open terminal and type 'killall dock' or, you could restart your computer.
    This should remove the finder icon from your dock, while still giving you access to it from your desktop.
    Hope this helps!
    -C

  • How can I remove the blocked contacts from skype h...

    Peace be upon you
    How can I remove the blocked contacts from skype home and all skype features?

    I found this solution and it worked.
    Paul B. Adams
    Re: safari 6.0 flash problem (blocked plug in) 
    Jul 26, 2012 7:39 AM (in response to defconnect5)
    I have a new MacBook Pro and I followed these instructions, downlonading and installing the new Flash plugin. But when I looked in "/Library/Internet Plugins" there was no folder called "Disabled Plugins".
    However, I did see two versions of Flash:
    _Flash Player.plugin with old date
    Flash Player.plugin with todays date
    I deleted _Flash Player.plugin and this fixed the problem.

  • How can I remove the Demo Viewer from my MacBook?

    How can I remove the Demo Viewer from my MacBook?

    Drag it to the Trash.
    Uninstalling Software: The Basics
    Most OS X applications are completely self-contained "packages" that can be uninstalled by simply dragging the application to the Trash.  Applications may create preference files that are stored in the /Home/Library/Preferences/ folder.  Although they do nothing once you delete the associated application, they do take up some disk space.  If you want you can look for them in the above location and delete them, too.
    Some applications may install an uninstaller program that can be used to remove the application.  In some cases the uninstaller may be part of the application's installer, and is invoked by clicking on a Customize button that will appear during the install process.
    Some applications may install components in the /Home/Library/Applications Support/ folder.  You can also check there to see if the application has created a folder.  You can also delete the folder that's in the Applications Support folder.  Again, they don't do anything but take up disk space once the application is trashed.
    Some applications may install a startupitem or a Log In item.  Startupitems are usually installed in the /Library/StartupItems/ folder and less often in the /Home/Library/StartupItems/ folder.  Log In Items are set in the Accounts preferences.  Open System Preferences, click on the Accounts icon, then click on the LogIn Items tab.  Locate the item in the list for the application you want to remove and click on the "-" button to delete it from the list.
    Some software use startup daemons or agents that are a new feature of the OS.  Look for them in /Library/LaunchAgents/ and /Library/LaunchDaemons/ or in /Home/Library/LaunchAgents/.
    If an application installs any other files the best way to track them down is to do a Finder search using the application name or the developer name as the search term.  Unfortunately Spotlight will not look in certain folders by default.  You can modify Spotlight's behavior or use a third-party search utility, EasyFind, instead.
    Some applications install a receipt in the /Library/Receipts/ folder.  Usually with the same name as the program or the developer.  The item generally has a ".pkg" extension.  Be sure you also delete this item as some programs use it to determine if it's already installed.
    There are many utilities that can uninstall applications.  Here is a selection:
        1. AppZapper
        2. AppDelete
        3. Automaton
        4. Hazel
        5. AppCleaner
        6. CleanApp
        7. iTrash
        8. Amnesia
        9. Uninstaller
      10. Spring Cleaning
    For more information visit The XLab FAQs and read the FAQ on removing software.

  • I inadvertently removed the junk mailbox from Mail.app in SL, how can I recreate / restore it ?

    Hi,
    Well, the title says it all : I inadvertently removed the junk mailbox from Mail.app in SL,
    it still is spresent in my ~/library/mail folder, how can I recreate / restore it in mail.app ?
    Since I have a fair number of email accounts, intelligent mailboxes, rules and archive folder, I really don't want to rebuild everything. And, no, I can't use time machine to restore it.
    All help will be greatly appreciated.

    Hi AdamKB, sorry for late follow-up.
    What I lost is the "container" that groups all junk mailboxes in one place in Mail, like is done for all the inboxes.
    The problem is that I lost visibility on all junk mailboxes. It is only a visibility problem because the junk mailboxes are still present locally for my POP accounts and remotely for may IMAP accounts, I justdon't see them anymore in Mail's interface.

  • How do I remove the back up from my c drive in my PC?

    How do I remove the back up from my c drive in my PC?

    This is where the backups are stored on the computer.
    Windows XP: \Documents and Settings\(username)\Application Data\Apple Computer\MobileSync\Backup\
    Windows Vista: \Users\(username)\AppData\Roaming\Apple Computer\MobileSync\Backup\
    Go to the appropriate folder and remove it.

  • My Mac G-4 OS X will not image an icon of the zip disk with I inserted into my computer's built-in Zip Drive, therefore I can not remove the zip disk from my computer.  What can I do?

    My Mac G-4 OS X will not image an icon of the zip disk with I inserted into my computer's built-in Zip Drive, therefore I can not remove the zip disk from my computer.  What can I do?

    Thanks Old Comm Guy, BD Aquam and Texas Mac Man for youradvice and reply to my question
    and problem with my Zip Drive.  However:
        1.  Depressing mouse buttonon start up did not eject the zip disk.
        2.  To examine front of zipdrive, I had to remove many screws and several plastic case
             coverings.  Upon doing thatI discovered that, unfortunately, there is no whole in front
              of mybuilt-in zip hardware drive for me to insert a paper clip to manually eject zipdisk.
          3.  I went to the Utilities folder in myMac OS X Application folder, but I could not find
               theiomega zip drive in there.
    Also, I did go into my "9" System folder and thento the Extensions folder within it and did find an icon of an
    Iomega Driver. When double clicking on it a window came upstating I was opening the application
    "ColorSync Extension" for thefirst time, and asking if I was sure I wanted to open this application.
    Uponclicking open nothing happened - nothing opened.
    I also went into the "System X" folder>Libraryfolder>Extension folder>IomegaSAM.ket icon and double
    clicked on it and asmall window opened stating "Compiling file List", however nothingopened it just
    continued to compile, so I closed it.
    Within my Mac OS X HD>  Applications>Iomega folder>Iomega Tools.app a smallwindow opened up
    with several options (Erase, Protect, Disk Info and DriveInfo). Clicking on the Drive Info a message says:
    "No Iomega Drives or noIomega Driver found.  Therefore, Ihave gone to Mac, Iomega and other websites
    trying to find a Driver for thebuilt-in Zip Drive in my Mac G-4 OS X 10.4.11, but have not really found anythat work.
    CAN ANYONE TELL ME IF THERE IS A WEBSITE WHERE I CANDOWNLOAD A NEW DRIVER FOR MY ZIP DRIVE?
    Thanks,     Peterfromcrystallake

  • I would like to be able to remove the 'bookmarks toolbar' from the bookmarks menu.

    Recently Firefox had a .. problem. I'm not sure what it was, or why. I just opened it one day and it had to 'reset'. So, it did, and i lost a bunch of things like addons and themes and stuff like that. Its not a big deal, because all the data was still there. Still, i have to fix some things again.
    I'm still using Firefox 15 - mostly because of some addons that aren't available in later ones, namely an addon that lets me make the window title Aero themed, i like that much more than the solid colours and i can't find one that works with later versions (anyone know of a way around that i would love to hear that too.
    Anyway, my question is simple I used to have the ability (i guess, an addon i've since forgotten about) to go to remove the 'bookmarks toolbar' from the Bookmarks menu. Also, i had a 'save all tabs' or something similar to that. Does anyone know an addon, or tweak, or anything that could get me that again?

    Sounds that you had a chrome folder with a userChrome.css file in it to do such a customization.
    *http://kb.mozillazine.org/userChrome.css
    *http://kb.mozillazine.org/Editing_configuration
    If you have the Old Firefox Data folder on the desktop then check that folder for the chrome folder and copy that folder to the current Firefox Profile Folder.
    You can use this button to go to the Firefox profile folder:
    *Help > Troubleshooting Information > Profile Directory: Show Folder
    See also:
    *[[/questions/877124]]

  • How do you remove the Messages icon from iPad.

    How can I remove the Messages icon from iPad.

    The preinstalled apps cannot be deleted. You can move it into a folder and place the folder on another screen if you don't want to use the app or see the icon.
    Tap and hold down on the icon until it begins wiggling and then drag the wiggling icon on top of another icon - any other app that you do not want to use would be ideal - and that will create a folder. Name the folder whatever you like. Tap anywhere outside of the folder to close it.
    While the folder and icons are still wiggling - drag the folder over to the edge of the screen - about halfway over - and just hold it there for a second or so and it will jump over to the next screen. When you are done - Tap the home button to stop the apps from wiggling.

  • How do I remove the superscript number from the Mail icon on the Dock?

    I have unsuccessfully  searched all folders and topics on the left side of the Mail page to find one supposed incoming email, as the Mail icon indicates with a numeral One on the Mail Icon in the dock to no avail.  How can I either find this unread email via a shortcut, or remove the superscript "1" from the Mail icon on the Dock? Thanks!

    Hmm, this seems kind of too obvious, but when I look at Mail, in the MAILBOXES sidebar on the left, every mailbox and folder has an oval to the right of its name listing how many unread messages it has.  (Sadly, I have a lot of ovals with big numbers in them!)
    Doesn't one of your ovals have a "1" in it?
    Hope that helps...
    Ivan

  • How to remove the open applications from right side of the dock?

    How do I remove the open apps from the right of the line on the dock? They are by the Trash. I will attach an image. I don't want them to show up over there when I have an app open.

    In previous versions of Mac OS X, any window containing an open application that was reduced in size was put in the Dock and looked like those in the image. So if you reduced any open page while in an application, that would be as you see, there. Or if you chose to 'hide' an open application it'd go there.
    You should be able to click once on each of those and have the full page restored in the screen. If there is anything on those pages you want to save, do so and the file would be saved in your Documents or other folder of your choosing.
    Good luck & happy computing!

Maybe you are looking for

  • Animated gif to html report

    Hello All Is it possible to save an animated GIF to a html report (for publishing to web and still maintain animation) Regards Ray

  • Safari 5.1.2 crashed on first use !

    Safari 5.1.1 used to crash quite a lot.  But it didn't crash on the first use !  Anyway, here is the crash log that might be of use: Process:         Safari [285] Path:            /Applications/Safari.app/Contents/MacOS/Safari Identifier:      com.ap

  • Program does not wait for user input

    Hi everyone, i am working on a program and there are 2 problems that i can't figure out. Since they are 2 different topics, I will do 2 posts. Just to give you some background on the program, it is a program that reads 3 txt files into 4 different ar

  • Parallels desktop 8

    Hello, my question is: for Parallels desktop 8 is better Macbook 13 or 15? MacBook Pro 13 •Intel Core i7 dual-core a 2,9GHz, Turbo Boost fino a 3,6GHz •8GB di SDRAM DDR3 a 1600MHz - 2x4GB •512GB - Unità a stato solido •SuperDrive 8x (DVD±R DL/DVD±RW/

  • Finder shows drives and folders, but no contents. It also won't show applications!

    I have a really odd issue with Finder. I plugged in an external LaCie Rugged to a MacBook Pro, the drive shows up and when I open it I can see all of the folders on the drive, but when I try to open them it says there is nothing in them! At first I t