问题
When I\'m validating my app I get this error:
the application bundle does not contain an icon in ICNS format, containing both a
512x512
and a512x512@2x
image.
I use to make the icns icons with Img2icns app and until today it always worked properly. But now I\'m getting that error and there\'s no way to make it work. I tried to put two PNG files together (512x512
and 1024x1024
) in Img2icns but I always get that error. I also tried to follow the instructions in Apple\'s OS X Human Interface Guideline but when I try to make the icon sets I get this terminal error:
-bash: syntax error near unexpected token \'newline\'
I am not very good with terminal commands so maybe I\'m doing something wrong. I wrote:
iconutil -c icns </Users/myname/SDK Mac Apps/MyApp/grafica/icon.iconset>
If anyone could help it would be very much appreciated. Thanks, Massy.
回答1:
Checkout the following instructions (link):
Use iconutil to Create an icns File Manually
The
iconutil
command-line tool convertsiconset
folders to deployment-ready, high-resolution icns files. (You can find complete documentation for this tool by enteringman iconutil
in Terminal.) Using this tool also compresses the resultingicns
file, so there is no need for you to perform additional compression.To convert a set of icons to an icns file
Enter this command into the Terminal window:
iconutil -c icns <iconset filename>
where
<iconset filename>
is the path to the folder containing the set of icons you want to convert toicns
. The output is written to the same location as theiconset file
, unless you specify an output file as shown:
iconutil -c icns -o <icon filename> <iconset filename>
In other words, you need to replace <iconset filename>
by the path:
/Users/myname/SDK Mac Apps/MyApp/grafica/icon.iconset
Since the path contains spaces, you need to use double quotes, for example:
iconutil -c icns "/Users/myname/SDK Mac Apps/MyApp/grafica/icon.iconset"
This command should work properly.
回答2:
Here's a script to convert a 1024x1024 png (named "Icon1024.png") to the required icns file. Save it to a filed called "CreateICNS.src" in the folder where your png file is then in terminal "cd" to the same folder and type "source CreateICNS.src" to call it:
mkdir MyIcon.iconset
sips -z 16 16 Icon1024.png --out MyIcon.iconset/icon_16x16.png
sips -z 32 32 Icon1024.png --out MyIcon.iconset/icon_16x16@2x.png
sips -z 32 32 Icon1024.png --out MyIcon.iconset/icon_32x32.png
sips -z 64 64 Icon1024.png --out MyIcon.iconset/icon_32x32@2x.png
sips -z 128 128 Icon1024.png --out MyIcon.iconset/icon_128x128.png
sips -z 256 256 Icon1024.png --out MyIcon.iconset/icon_128x128@2x.png
sips -z 256 256 Icon1024.png --out MyIcon.iconset/icon_256x256.png
sips -z 512 512 Icon1024.png --out MyIcon.iconset/icon_256x256@2x.png
sips -z 512 512 Icon1024.png --out MyIcon.iconset/icon_512x512.png
cp Icon1024.png MyIcon.iconset/icon_512x512@2x.png
iconutil -c icns MyIcon.iconset
rm -R MyIcon.iconset
回答3:
There's a command-line node module that does all the work of converting a PNG file into an iconset directory:
npm install -g node-icns
nicns --in adventure-cat.png --out adventure-cat.icns
回答4:
While using all kinds of scripts to convert hi-res PNG
image to a pleiad of different low-resolution copies may seem handy (and it really is), one should not forget that this kind of automatic resizing will render perceptibly imperfect images.
The lesser the resolution, the blurrier the icon!
Instead, you should always request a logo in some vector format from your designer, for example in SVG
. With this on hand, you can manually prepare perfect PNG files in all required resolutions and then make a single .icns
file, which will make your app icon look beautiful on every single screen, from mobile phone to some high-end Retina display of the latest iMac.
From the latest Apple guideline as of 2016, you should prepare the following PNG files:
+---------------------+--------------------+--------------+
| filename | resolution, pixels | density, PPI |
+---------------------+--------------------+--------------+
| icon_16x16.png | 16x16 | 72 |
| icon_16x16@2x.png | 32x32 | 144 |
| icon_32x32.png | 32x32 | 72 |
| icon_32x32@2x.png | 64x64 | 144 |
| icon_128x128.png | 128x128 | 72 |
| icon_128x128@2x.png | 256x256 | 144 |
| icon_256x256.png | 256x256 | 72 |
| icon_256x256@2x.png | 512x512 | 144 |
| icon_512x512.png | 512x512 | 72 |
| icon_512x512@2x.png | 1024x1024 | 144 |
+---------------------+--------------------+--------------+
After all the PNG files are prepared, place them into some directory with .iconset
extension (Logos.iconset
for example) and execute the following from the Terminal:
iconutil --convert icns Logos.iconset
If there were no errors after executing this command, then all the files were processed properly, and you got the Logos.icns
file in the same directory, containing all the beautiful crisp logos for your app which will suit any modern screen as of 2017.
回答5:
These commands (entered in Terminal) worked for me to convert an old icns file to the new format:
cd Folder_With_Icns_File
iconutil -c iconset Your_Icon_Name.icns
rm Your_Icon_Name.icns
iconutil -c icns Your_Icon_Name.iconset
rm -R Your_Icon_Name.iconset
Update
The -c
parameter to iconutil is no longer supported. Use --convert
instead:
cd Folder_With_Icns_File
iconutil --convert iconset Your_Icon_Name.icns
rm Your_Icon_Name.icns
iconutil --convert icns Your_Icon_Name.iconset
rm -R Your_Icon_Name.iconset
回答6:
Additional comment, when you create .icns file, you need to rename all the pic files with prefix "icon_", otherwise, iconutil will fail with error message: ".iconset:error: Failed to generate ICNS." which is not informative at all.
回答7:
I have written a bash script for making icns from a svg file:
#!/usr/bin/env bash
sizes=(16 32 64 128 256 512)
largfile='icon_512x512@2x.png'
if [ ! -f "$largfile" ]; then
convert -background none -resize 1024x1024 "$1" "$largfile"
fi
for s in "${sizes[@]}"; do
echo $s
convert -background none -resize ${s}x${s} "$largfile" "icon_${s}x$s.png"
done
cp 'icon_32x32.png' 'icon_16x16@2x.png'
mv 'icon_64x64.png' 'icon_32x32@2x.png'
cp 'icon_256x256.png' 'icon_128x128@2x.png'
cp 'icon_512x512.png' 'icon_256x256@2x.png'
mkdir icon.iconset
mv icon_*x*.png icon.iconset
iconutil -c icns icon.iconset
Make sure you have imagemagick installed with librsvg support, on mac:
brew install imagemagick --with-librsvg
This script has served me quite well.
Update
For a more thorough treatment, I have created a command line tool (written in Swift) for generating AppIcon.appiconset
with the correct layout and format:
https://github.com/kindlychung/genicon
回答8:
Same as @Henry (comment above) but takes as argument the PNG filename and outputs the ICNS with the same name.
NOTE : The PNG file name is only expected to have 1 point to separate extension, i.e. xpto.png .
So, save the code below to a filed called "CreateICNS.src" in the folder where your png file is.
CODE :
IFS='.' read -ra ADDR <<< "$1"
ICONSET=${ADDR[0]}.iconset
mkdir $ICONSET
sips -z 16 16 $1 --out $ICONSET/icon_16x16.png
sips -z 32 32 $1 --out $ICONSET/icon_16x16@2x.png
sips -z 32 32 $1 --out $ICONSET/icon_32x32.png
sips -z 64 64 $1 --out $ICONSET/icon_32x32@2x.png
sips -z 128 128 $1 --out $ICONSET/icon_128x128.png
sips -z 256 256 $1 --out $ICONSET/icon_128x128@2x.png
sips -z 256 256 $1 --out $ICONSET/icon_256x256.png
sips -z 512 512 $1 --out $ICONSET/icon_256x256@2x.png
sips -z 512 512 $1 --out $ICONSET/icon_512x512.png
cp $1 $ICONSET/icon_512x512@2x.png
iconutil -c icns $ICONSET
rm -R $ICONSET
HOW TO USE :
Then in the terminal, "cd" to the same folder and type :
source CreateICNS.src {PNG filename}
where {PNG filename} is the name of your PNG file, i.e. xpto.png .
If your file would be named abc.png you would use :
source CreateICNS.src abc.png
回答9:
I've refactored @Henry's script to make it look better:
#!/bin/zsh
NAME=$(basename $1 .png); DIR="$NAME.iconset"
mkdir -pv $DIR
for m r in 'n' '' '((n+1))' '@2x'; do
for n in $(seq 4 9 | grep -v 6); do
p=$((2**$m)); q=$((2**$n))
OUT="$DIR/icon_${q}x${q}${r}.png"
sips -z $p $p $1 --out $OUT
done
done
iconutil -c icns $DIR
rm -frv $DIR
Update
The -c
parameter to iconutil is no longer supported. Use -—convert
instead:
#!/bin/zsh
NAME=$(basename $1 .png); DIR="$NAME.iconset"
mkdir -pv $DIR
for m r in 'n' '' '((n+1))' '@2x'; do
for n in $(seq 4 9 | grep -v 6); do
p=$((2**$m)); q=$((2**$n))
OUT="$DIR/icon_${q}x${q}${r}.png"
sips -z $p $p $1 --out $OUT
done
done
iconutil -—convert icns $DIR
rm -frv $DIR
回答10:
Dead simple .png 👉 .icns
- Download IconMaker.app - It's just an .applescript won't bite
- Drag and drop your .png onto the IconMaker.app you just created.
More info: http://eon.codes/blog/2016/12/06/Creating-an-app-icon/
High sierra update iconutil
is now more strict about the source .png size. More about this in the blog post after the jump. ✌️
回答11:
When I'm validating my app I get this error:
the application bundle does not contain an icon in ICNS format, containing both a 512x512 and a 512x512@2x image.
⋮
I am not very good with terminal command and so maybe I'm doing something wrong. I wrote:
iconutil -c icns </Users/myname/SDK Mac Apps/MyApp/grafica/icon.iconset>
For one thing, as I mentioned in a comment on Anne's answer, you probably don't need to use iconutil. You should be able to just add the iconset to your project and let Xcode convert it for you as part of the build.
Either way, this may be your problem:
I tryed to put two PNG files togheter (512x512 and 1024x1024) … but I always get the error.
There is no 1024 by 1024 point size. The 1024 by 1024 pixel element (which was 1024 points before Mountain Lion) is now used for 512 by 512 points @2x.
Your PNG file must be named appropriately: icon_512x512@2x.png
回答12:
Apple's older Icon Composer version 2.2 works just fine, you just open the .ICNS in it, press the 1024x1024 button and add your image.
回答13:
@dardo82's shell code is good & worked. Here is a simpler one in sh (for all *nix's) and faster (like it really matters):
#!/bin/sh
# This runs silent, be as verbose as you wish
NAME=$(basename ${1} .png)
DIR="${NAME}.iconset"
mkdir -p ${DIR}
for i in 16 32 128 256 512 ; do
x=""
for p in $i $(($i+$i)) ; do
sips -z $p $p ${1} --out "${NAME}.iconset/icon_${i}x${i}${x}.png"
x="@2x"
done
done >/dev/null # /dev/null in lieu of a "-s" silent option
iconutil -—convert icns $DIR
rm -r $DIR
回答14:
Run iconutil -c icns Icon.iconset
Note
- Icon.iconset is a folder
- Name start with lowercase
icon_
- When you see
Icon.icns
with correct image, you know it works
回答15:
Here's a function mostly based off Henry's example (could be useful in ~/.bash_profile
):
mkicns() {
if [[ -z "$*" ]] || [[ "${*##*.}" != "png" ]]; then
echo "Input file invalid"
else
filename="${1%.*}"
mkdir "$filename".iconset
for i in 16 32 128 256 ; do
n=$(( i * 2 ))
sips -z $i $i "$1" --out "$filename".iconset/icon_${i}x${i}.png
sips -z $n $n "$1" --out "$filename".iconset/icon_${i}x${i}@2x.png
[[ $n -eq 512 ]] && \
sips -z $n $n "$1" --out "$filename".iconset/icon_${n}x${n}.png
(( i++ ))
done
cp "$1" "$filename".iconset/icon_512x512@2x.png
iconutil -c icns "$filename".iconset
rm -r "$filename".iconset
fi
}
Usage:
$ mkicns "filename.png" # double-quote if spaces exist in filename
Creates 10 sizes from
16x16
to512x512@2x
; accepts input images in.png
format only.
回答16:
There are 2 tasks:
- create 10 correct icns files
- get your Xcode project to use them correctly
As I had hour long problems with both of these tasks, and also do not like when I don't 'see' what is going on, here a path for the cautious ones:
Create 10 correct icns files:
I used the script above from Henry: It still works for HighSierra and Xcode 9.2, including the 'c' command.
The icns file I got, appeared as only one icon size in Finder/Quicklook and in Preview showed only 8 of 10 sizes.
So I used terminal, went with cd to my folder and used the command: iconutil -c iconset (icns filename) on the just created icns file to revert the icns file back to an iconset folder, and - lo & behold - I could see my newly created 10 icon files. Using Quick look on the iconset folder (and using full screen mode to be able to zoom through them with the slider), I could check that all sizes are actually looking very well.
As an aside: they looked better than my resizing attempts with PSE, most likely because I did not take the time to play with all the resizing options in PSE. If you do use PSE, make sure your png files are saved without colour profile. Also, confessing my ignorance, for me a 256x256@2 file is the same as a 512x512 file - both in 72dpi. Trying to follow the 144 dpi comments above did not work for me.
Get your Xcode project to use them correctly:
First I deleted all my fruitless attempts within Xcode and committed a clean version to the git repository (what would have been clever, would have been to commit a clean version first - before I frantically started the icon addition odyssee).
I also made sure that in the info.plist file there is no pointer linked to the 'icon file' entry and that in my General project settings I had chosen AppIcon for App Icons.
Then I added an assets.asset catalog and within the assets catalog a new 'AppIcons and Launch Images' AppIcon Folder for OS.
Then I copied (drag and drop with option pressed) from the iconset folder each png picture file into the respective AppIcon Spaceholder. So again, I could see what is happening. Xcode did convert that into icns files, or maybe - as my iconset folder derived from an icns folder - the file formats were accepted.
Then archive and validate and there will be no errors upon uploading or validating.
回答17:
I needed this, but for CMake. I also wanted the option of giving it an SVG.
Here is the gist: https://gist.github.com/Qix-/f4090181e55ea365633da8c3d0ab5249
And the CMake code:
# LICENSE: CC0 - go nuts.
# Hi :) This is what I used to generate the ICNS for my game, Tide.
# Both input formats (SVG vs PNG) work just fine, but in my experience
# the SVG came out with noticeably better results (although PNG wasn't
# a catastrophe either). The logo for the game was simple enough that
# SVG was indeed an option.
# To use:
#
# make_icns( INPUT "path/to/img.{svg,png}"
# OUTPUT ICNS_PATH )
#
# Then add it as a custom target or use it as a
# dependency somewhere - I give you that option.
#
# For example:
#
# add_custom_target( my-icns ALL DEPENDS "${ICNS_PATH}" )
#
# For the associated utilities:
#
# - PNG: brew install imagemagick
# - SVG: brew cask install inkscape
#
# Enjoy!
function (make_icns_from_png)
cmake_parse_arguments (
ARG
"" # Boolean args
"INPUT;OUTPUT" # List of single-value args
"" # Multi-valued args
${ARGN})
find_program (
convert_exe
NAMES "convert" "convert.exe"
DOC "Path to ImageMagick convert")
if (NOT convert_exe)
message (FATAL_ERROR "Could not find ImageMagick's 'convert' - is ImageMagick installed?")
endif ()
get_filename_component (ARG_INPUT_ABS "${ARG_INPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
get_filename_component (ARG_INPUT_ABS_BIN "${ARG_INPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
get_filename_component (ARG_INPUT_FN "${ARG_INPUT_ABS_BIN}" NAME_WE)
get_filename_component (ARG_INPUT_DIR "${ARG_INPUT_ABS_BIN}" DIRECTORY)
set (sourceimg "${ARG_INPUT_ABS}")
set (basepath "${ARG_INPUT_DIR}/${ARG_INPUT_FN}")
set (output_icns "${basepath}.icns")
set (iconset "${basepath}.iconset")
set (deplist "")
foreach (size IN ITEMS 16 32 128 256 512)
math (EXPR size2x "2 * ${size}")
set (ipath "${iconset}/icon_${size}x${size}.png")
set (ipath2x "${iconset}/icon_${size}x${size}@2x.png")
list (APPEND deplist "${ipath}" "${ipath2x}")
add_custom_command (
OUTPUT "${ipath}"
COMMAND "${convert_exe}" ARGS "${sourceimg}" -resize "${size}x${size}" "${ipath}"
MAIN_DEPENDENCY "${sourceimg}"
COMMENT "ICNS resize: ${ipath}"
VERBATIM)
add_custom_command (
OUTPUT "${ipath2x}"
COMMAND "${convert_exe}" ARGS "${sourceimg}" -resize "${size2x}x${size2x}" "${ipath2x}"
MAIN_DEPENDENCY "${sourceimg}"
COMMENT "ICNS resize: ${ipath2x}"
VERBATIM)
endforeach ()
add_custom_command (
OUTPUT "${output_icns}"
COMMAND iconutil ARGS --convert icns --output "${output_icns}" "${iconset}"
MAIN_DEPENDENCY "${sourceimg}"
DEPENDS ${deplist}
COMMENT "ICNS: ${output_icns}"
VERBATIM)
if (ARG_OUTPUT)
set ("${ARG_OUTPUT}" "${output_icns}" PARENT_SCOPE)
endif ()
endfunction ()
function (make_icns_from_svg)
cmake_parse_arguments (
ARG
"" # Boolean args
"INPUT;OUTPUT" # List of single-value args
"" # Multi-valued args
${ARGN})
set (CMAKE_FIND_APPBUNDLE NEVER) # otherwise, it'll pick up the app bundle and open a shit ton of windows
find_program (
inkscape_exe
NAMES "inkscape" "inkscape.exe"
DOC "Path to Inkscape"
PATHS "/usr/local/bin" "/usr/bin")
message (STATUS "Inkscape path: ${inkscape_exe}")
if (NOT inkscape_exe)
message (FATAL_ERROR "Could not find Inkscape - is it installed?")
endif ()
get_filename_component (ARG_INPUT_ABS "${ARG_INPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
get_filename_component (ARG_INPUT_ABS_BIN "${ARG_INPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
get_filename_component (ARG_INPUT_FN "${ARG_INPUT_ABS_BIN}" NAME_WE)
get_filename_component (ARG_INPUT_DIR "${ARG_INPUT_ABS_BIN}" DIRECTORY)
set (sourceimg "${ARG_INPUT_ABS}")
set (basepath "${ARG_INPUT_DIR}/${ARG_INPUT_FN}")
set (output_icns "${basepath}.icns")
set (iconset "${basepath}.iconset")
set (deplist "")
foreach (size IN ITEMS 16 32 128 256 512)
math (EXPR size2x "2 * ${size}")
set (ipath "${iconset}/icon_${size}x${size}.png")
set (ipath2x "${iconset}/icon_${size}x${size}@2x.png")
list (APPEND deplist "${ipath}" "${ipath2x}")
add_custom_command (
OUTPUT "${ipath}"
COMMAND "${inkscape_exe}" ARGS -z -e "${ipath}" -w ${size} -h ${size} "${sourceimg}"
MAIN_DEPENDENCY "${sourceimg}"
COMMENT "ICNS resize: ${ipath}"
VERBATIM)
add_custom_command (
OUTPUT "${ipath2x}"
COMMAND "${inkscape_exe}" ARGS -z -e "${ipath2x}" -w ${size2x} -h ${size2x} "${sourceimg}"
MAIN_DEPENDENCY "${sourceimg}"
COMMENT "ICNS resize: ${ipath2x}"
VERBATIM)
endforeach ()
add_custom_command (
OUTPUT "${output_icns}"
COMMAND iconutil ARGS --convert icns --output "${output_icns}" "${iconset}"
MAIN_DEPENDENCY "${sourceimg}"
DEPENDS ${deplist}
COMMENT "ICNS: ${output_icns}"
VERBATIM)
if (ARG_OUTPUT)
set ("${ARG_OUTPUT}" "${output_icns}" PARENT_SCOPE)
endif ()
endfunction ()
function (make_icns)
cmake_parse_arguments (
ARG
"" # Boolean args
"INPUT;OUTPUT" # List of single-value args
"" # Multi-valued args
${ARGN})
if (NOT ARG_INPUT)
message (FATAL_ERROR "INPUT is required")
endif ()
if (NOT IS_ABSOLUTE "${ARG_INPUT}")
get_filename_component (ARG_INPUT "${ARG_INPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
endif ()
if (NOT EXISTS "${ARG_INPUT}")
message (FATAL_ERROR "INPUT does not exist: ${ARG_INPUT}")
endif ()
file (RELATIVE_PATH ARG_INPUT "${CMAKE_CURRENT_SOURCE_DIR}" "${ARG_INPUT}")
get_filename_component (ARG_INPUT_EXT "${ARG_INPUT}" EXT)
if ("${ARG_INPUT_EXT}" STREQUAL ".png")
make_icns_from_png (INPUT "${ARG_INPUT}" OUTPUT child_output)
elseif ("${ARG_INPUT_EXT}" STREQUAL ".svg")
make_icns_from_svg (INPUT "${ARG_INPUT}" OUTPUT child_output)
else ()
message (FATAL_ERROR "INPUT must refer to a .png or .svg, but a ${ARG_INPUT_EXT} was provided")
endif ()
if (ARG_OUTPUT)
set ("${ARG_OUTPUT}" "${child_output}" PARENT_SCOPE)
endif ()
endfunction ()
回答18:
Hello, for my needs I made a droplet that works in drag and drop icons alone or icons to search in a folder (I limited to folders as the searches on Volumes of all the icons can take a lot of time ). So in drag and drop you can drop folders or application, anything that can contain an icon. The iconset created bears the name of the original icon, it is placed in a directory "/ aaaicones" and the path of the icon. Example in the folder "/ aaaicones if you submit xcode.app you will find "/aaaicones/Applications/xcode.app/access.iconset" and /aaaicones/Applications/xcode.app/access.icns (the recreated icon) there will be a text file where it is traced the full path of the icons , And the path to the corresponding iconset example "/Applications/xcode.app/Contents/Applications/Instruments.app/Contents/Frameworks/InstrumentsPlugIn.framework/Versions/A/Resources/access.icns" "/aaaicones/Applications/xcode.app/access.iconset" in the example taken (xcode) this can create a folder at the end (with all icons and iconset) of 214 MB in size. If you treat an icon alone, it will be placed in the directory "/ aaaicones / aIconeseule /" and its original path, example /aaaicones/aIconeseule/Mac Elcapitan/.VolumeIcon.icns and /aaaicones/aIconeseule/Mac Elcapitan /.VolumeIcon.iconset with /aaaicones/aIconeseule/Mac Elcapitan/aalisticones.txt The droplet is below
on open draggedItems
set input to draggedItems
set fich to draggedItems
set media to {}
set theInfo to {}
set n to "0"
repeat with currentItem in draggedItems
set dirchoisi to POSIX path of fich
if ".icns" is not in dirchoisi then
if "Volumes" is not in dirchoisi then
set origi to do shell script "echo /aaaicones" & dirchoisi
set fich to do shell script "echo " & fich & " | xxd -p -c 100000 | sed 's#3a#2f#g' | xxd -r -p | sed 's#" & dirchoisi & "#" & "/aaaicones" & dirchoisi & "#g' | xxd -p -c 100000 | sed 's#2f#3a#g' | xxd -r -p"
tell application "Finder"
if exists (folder fich) then
set nn to "0"
repeat with nn from 1 to 5
set origi to do shell script "echo " & origi & "/" & " | sed 's#//#" & nn & "/" & "#'"
set fich to do shell script "echo " & fich & " | sed 's#:aaaicones*.*#" & origi & "#'" & " | xxd -p -c 100000 | sed 's#2f#3a#g' | xxd -r -p"
if not (exists folder (fich as Unicode text)) then
try
set origi to do shell script "echo " & origi
exit repeat
end try
end if
end repeat
end if
end tell
tell application "Finder"
if not (exists folder (fich as Unicode text)) then
do shell script "mkdir -p -m 0777 " & quoted form of origi
end if
end tell
try
set theInfo to do shell script "find " & (quoted form of dirchoisi) & " -name *.icns "
end try
set AppleScript's text item delimiters to return
set theList to text items of theInfo
set AppleScript's text item delimiters to ""
set n to count theList
repeat with i from 1 to n
if "Volumes" is not in item i of theList then
set end of media to item i of theList
end if
end repeat
set n to count media
set cheminicns to do shell script " > " & quoted form of (origi & "aalisticones.txt") & " | chmod 777 " & quoted form of (origi & "aalisticones.txt")
set cheminicns to do shell script "ls " & quoted form of (origi & "aalisticones.txt")
tell application "Finder"
set letext to (POSIX file cheminicns as alias)
set label index of letext to 2
end tell
repeat with i from 1 to n
set hdd to item i of media
try
set input to do shell script "echo " & hdd & " | sed 's#//#/#g; s#(#\\(#g;s#)#\\)#g' "
do shell script "echo " & quoted form of input & " >>" & quoted form of cheminicns
set png to do shell script "echo " & quoted form of input & " | sed 's#.*/##' "
do shell script "cp -f " & quoted form of input & " " & quoted form of origi
set input to do shell script "iconutil -c iconset " & quoted form of (origi & png)
do shell script "echo " & quoted form of (origi & png) & " | sed 's#.icns#.iconset#' >>" & quoted form of cheminicns
end try
end repeat
tell application "Finder"
if exists (folder fich) then
open fich
end if
end tell
end if
else
set input to do shell script "echo " & dirchoisi & " | sed 's#//#/#g; s#(#\\(#g;s#)#\\)#g' "
set png to do shell script "echo " & quoted form of input & " | sed 's#.*/##' "
set origi to do shell script "echo " & quoted form of ("/aaaicones/aIconeseule/" & input) & " | sed 's#/Volumes/##; s#" & quoted form of png & "##'"
do shell script "mkdir -p -m 0777 " & quoted form of origi
do shell script "echo " & quoted form of input & " >>" & quoted form of origi & "aalisticones.txt"
do shell script "cp -f " & quoted form of input & " " & quoted form of origi
set input to do shell script "iconutil -c iconset " & quoted form of (origi & png)
do shell script "echo " & quoted form of (origi & png) & " >>" & quoted form of origi & "aalisticones.txt"
end if
end repeat
end open
来源:https://stackoverflow.com/questions/12306223/how-to-manually-create-icns-files-using-iconutil