Как скопировать файл без расширения

Обновлено: 07.07.2024

Установив операционную систему, большинство опытных пользователей включают отображение расширения файлов. И правильно делают, ведь благодаря расширению можно легко определить тип файла и подыскать при необходимости для его просмотра подходящую программу. Увы, не все файлы, даже те, которые можно найти на просторах интернета, имеют расширение. С объектами без расширения вы можете столкнуться при поиске и восстановлении удаленных файлов.

А также при разборе прошивок, при декодировании строки из Base64 и тому подобное.

Как быть в этом случае, можно ли как-то определить тип такого объекта?

Можно, хотя это и требует определенных усилий и навыков.

В таких случаях можно воспользоваться специальными утилитами, анализирующими специфические наборы байтов, располагающиеся не в начале файла, как заголовки, а немного ниже. Примером таких наборов байтов служат так называемые magic number, сообщающие UNIX-системам, что файл является исполняемым, впрочем, концепция магических чисел применима не только к исполняемым, но и ко всем бинарным файлам. Соответственно, в операционных системах UNIX для определения типа любого двоичного файла предусмотрена специальная команда file .

Чтобы иметь возможность использовать эту команду в Windows, нужно установить Cygwin — программный пакет, реализующий в Windows Unix-подобную среду и позволяющий выполнять наиболее распространенные команды Linux.

Установив пакет с настройками по умолчанию, запускаем командную строку Cygwin и выполняем команду file "полный путь к файлу без расширения" . Если файлов несколько, команда будет немного иной: file D:/folder/* . Обратите внимание, что во второй команде мы не заключаем путь к содержащей файлы папке folder в прямые кавычки и используем обычные (не обратные) слеши.

Cygwin

Команда file не показывает, собственно, расширение файла, она служит для определения его типа, так, на представленном выше скриншоте можно видеть, что файл 2452323 является текстовым документом с разметкой XML , файл f4ed4f25 — это изображение JPEG , а start — текстовый файл в кодировке UTF-16 Unicode .

Если вы не хотите ставить Cygwin, можете воспользоваться тулзой file-windows — скомпилированными в экзешник файлами линуксовой утилиты file.

Запустите командную строку, перейдите в папку с исполняемым файлом и выполните команду следующего вида file.exe полный путь к файлу без расширения .

CMD File

Или в PowerShell команда будет выглядеть немного иначе: ./file.exe 'полный путь к файлу без расширения' .

PowerShell File

Утилита TrID

В отличии от file, кроссплатформенная утилита TrID позволяет более или менее точно определять расширение файла, благодаря подключаемой к ней базе сигнатур.

Download

Создайте отдельную папку и распакуйте в нее оба скачанных архива.

Откройте Powershell , перейдите в расположение исполняемого файла утилиты и выполните команду ./trid.exe 'полный путь к файлу без расширения' . В результате утилита выведет несколько вариантов с процентным соотношением вероятности соответствия тому или иному расширению.

TrID

Если нужно проанализировать сразу несколько файлов, указываем путь только к содержащему их каталогу, не забывая об подстановочном знаке — звездочке, вот так: ./trid.exe 'Диск:/папка/*' . В случае сканирования сразу нескольких файлов утилита выведет только один вариант расширения — самый вероятный.

TrID File Type

Существуют также и другие подобные TrID утилиты, например, Detect It Easy с удобным графическим интерфейсом.


Сегодня рассмотрим, как создать файл без расширения средствами операционных систем Windows без применения сторонних решений, а также при помощи бесплатных приложений, которыми пользуются миллионы людей. В самой ОС не предусмотрена подобная функция, однако это легко обойти, зная несколько секретов.

Командная строка

Универсальный инструмент, посредством которого в Windows можно сделать совершенно всё, главное, знать, каким образом.

  1. Запускаем командную строку любым удобным способом, например, жмём Win + R, а в появившемся окошке выполняем команду «cmd».
  2. В открывшемся окне с черным фоном вводим и выполняем команду «copy con>file» либо «1 >> c:\file», где file – название нашего документа. Можно вводить полный путь к файлу, если пользоваться командной строкой не умеете. Это избавит от необходимости переходить в нужный каталог в текстовом режиме.

Внимания на предупреждения или ошибки не обращаем, свою функцию команда выполнит.

Это самый простой, универсальный и быстрый способ создать пустой файл без расширения в любой версии Windows 7. Все остальные на «Семёрке» и «Десятке» будут незначительно отличаться из-за различий в интерфейсе.

Проводник

Через стандартный менеджер файлов также можно сделать файл без расширения.

  1. Для этого открываем каталог, в котором он должен появиться.
  2. Кликаем правой клавишей мыши на пустом месте в окне и вызываем пункт «Новый».
  3. В выпавшем списке выбираем любой пункт кроме первого.

Появится файл, название которого следует ввести.


  1. Вводим имя нового документа без точек или удаляем точку и жмём «Enter».


  1. Соглашаемся с тем, что после изменения расширения (оно идёт после точки и служит идентификатором для данного типа файлов) документ может стать недоступным.


На этом – всё готово.

Вместо создания нового документа через контекстное меню можно сделать копию любого файла и переименовать его, однако в таком случае документ будет занимать определённое место.Если он не является текстовым, открыть такой объект через блокнот будет невозможно (по крайней мере для нормальной работы с ним).

Windows 7

  1. Открываем Проводник, например, при помощи сочетания горячих клавиш Win + E.
  2. Кликаем Alt для вызова главного меню, если оно невидимо.
  3. Из него вызываем пункт «Сервис», в выпавшем списке выбираем «Параметры папок».


  1. Идём во вкладку «Вид».
  2. В фрейме «Дополнительные параметры» пролистываем список пунктов до самого низа и убираем флажок возле опции «Скрывать расширения для…».
  3. Сохраняем новую конфигурацию.


Теперь возможность изменения расширения документов доступна.

Windows 10

В Windows 8 и 10 активация и отключение функции осуществляется проще и быстрее.

  1. В Проводнике вызываем главное меню при помощи Alt, если оно спрятано.
  2. Во вкладке «Вид» отмечаем галочкой опцию «Расширение имён файлов».


Для открытия и изменения содержимого документа его необходимо перетащить в окно любого текстового редактора или через контекстное меню вызвать команду «Открыть с помощью…» и выбрать нужное приложение в выпадающем списке.

Этих способов решения проблемы вполне достаточно для всех случаев, однако мы коснёмся ещё пары вариантов решения задачи для исчерпания темы.

Блокнот

Стандартный текстовый редактор Windows не способен помочь в данной ситуации – он автоматически дописывает расширение после названия документа, даже если его не ставить.

  1. Скачиваем приложение с официального сайта, инсталлируем и запускаем его.
  2. Жмём Ctrl + S либо вызываем команду «Сохранить» через пункт главного меню «Файл».
  3. Вводим название документа, в поле «Тип…» указываем «AllFiles (*.*)» и кликаем «Сохранить».


Total Commander

Самый популярный и функциональный файловый менеджер для Windows также позволяет в несколько кликов создать файл без расширения.

  1. Открываем целевой каталог и вызываем контекстное меню папки правым кликом по пустому месту панели.
  2. Выбираем знакомый пункт «Новый» и указываем любой объект, кроме папки и ярлыка.


  1. В окошке для ввода имени пишем любое название без точки и кликаем «ОК» для создания нового объекта.


Также задачу можно решить, переименовав любой файл путём удаления точки из его названия.

Мы рассмотрели основные способы создания файлов без расширения в операционных системах Windows при помощи инструментария самой ОС и посредством популярных приложений.

Конфигурация компьютера
Процессор: Intel PentiumM 1.4
Материнская плата: Acer TM 4050
Память: Nanya, DDR, 512
HDD: Samsung, 120Gb, Pata
Видеокарта: Intel integr
Звук: integr (Realtek)
Блок питания: 120
CD/DVD: CD/DVD-RW
Монитор: Acer, 14
ОС: WinXP pro, Mandriva
Вот собственно сабж.
Во-первых нужно научиться копировать файл без расширения. Например, вот этот путь - @WindowsDir&'\System32\Drivers\Etc\hosts' воспринимается как папка.
А еще неплохо было бы иметь возможность переименовать, опять-же на этом примере, файл hosts.txt в просто hosts
У кого есть конструктивные мысли?

-------
ira furor brevis est

Для отключения данного рекламного блока вам необходимо зарегистрироваться или войти с учетной записью социальной сети.

Конфигурация компьютера
Процессор: Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz, 3701 МГц, ядер: 4, логических процессоров: 4
Материнская плата: Gigabyte Technology Co., Ltd. BIOS American Megatrends Inc. F11, 21.08.2012
Память: G.Skill 4096 Мб (DDR3), Corsair 8192 Мб (DDR3)
HDD: WDC WD10EALX-009BA0 ATA Device
Видеокарта: NVIDIA GeForce GT 220
Звук: VIA Technologies, Inc.
Монитор: Fujicom 200804220001 (23)
ОС: Windows 10 Professional x64
этот путь - @WindowsDir&'\System32\Drivers\Etc\hosts' воспринимается как папка »
Но ведь насколько мне известно, в одном месте не может содержаться и папка и файл с одним и тем же именем (файл без расширения).

-------
“Сделай так просто, как возможно, но не проще этого.”. “Ты никогда не решишь проблему, если будешь думать так же, как те, кто её создал.”

Решено: Копирование файлов с определенным расширением.

Модератор: SLEDopit

Решено: Копирование файлов с определенным расширением.

Здравствуйте.
Хоть вы подскажите какой командой можно скопировать все файлы с определенным расширением.
То есть есть директория в которой куча хлама, и куча директорий в которых опять же директории и хлам.

Мне нужно сделать скрипт который будет копировать с этой директории все файлы имеющие расширение mp3 mp4 avi
Пример

В этом случаи копируется содержимое dir1 со всеми папками и файлами. Но нужно тока с папками и файлами определенного расширения.

В итоге нужно получить

без лишних rgr.txt ooo.sh

Это как раз то что мне нужно с малыми недостатками, но то что нужно )))
Оно создало сетку директорий даже если в них нету нужных форматов.
Но это уже шаг. Во истину благодарен . Опция -m, она же --prune-empty-dirs
Вообще, почитайте man rsync.
тока и при присутствии ключа m тоже копируются все директории даже если в них нету нужных расширений.
man по rsync там как правила ключи и примеры работы для создание бекапов, и что то я не смог разобраться как записать ключи для выполнение этой задачи. Мне нужно сделать скрипт который будет копировать с этой директории все файлы имеющие расширение mp3 mp4 avi find \( -name "*.mp3" -o -name "*.mp4" -o -name "*.avi" \) -exec cp --parents -v -t target_dir/ <> +
мда. Настоящий линуксоид не ищет трудностей, он сам их придумывает. Ненужность rsync для локальных файлов уже обсуждалась.

Скоро придёт
Осень


Но с rsync было понятнее. А где здесь указывать откуда и куда ? find \( -name "*.mp3" -o -name "*.mp4" -o -name "*.avi" \) -exec cp --parents -v -t target_dir/ <> + Солнце садилось в море, а люди с неоконченным высшим образованием выбегали оттуда, думая, что море закипит.

Скоро придёт
Осень

для ускорения команды желательно, что-бы одна cp копировала сразу группу файлов. для этого есть специальный синтаксис:

--parents нужно для того, что-бы при копировании ./dir1/dir2/file1 автоматически создавались target_dir/dir1 и target_dir/dir1/dir2.

ну и наконец, + в find пихает все найденные файлы в хвост команды (файл1 файл2 файл3 файл4. ). (точнее обычно все, если они влезают)

FILTER RULES
The filter rules allow for flexible selection of which files to transfer (include) and which files to skip
(exclude). The rules either directly specify include/exclude patterns or they specify a way to acquire
more include/exclude patterns (e.g. to read them from a file).

As the list of files/directories to transfer is built, rsync checks each name to be transferred against
the list of include/exclude patterns in turn, and the first matching pattern is acted on: if it is an
exclude pattern, then that file is skipped; if it is an include pattern then that filename is not skipped;
if no matching pattern is found, then the filename is not skipped.

Rsync builds an ordered list of filter rules as specified on the command-line. Filter rules have the fol‐
lowing syntax:

RULE [PATTERN_OR_FILENAME]
RULE,MODIFIERS [PATTERN_OR_FILENAME]

You have your choice of using either short or long RULE names, as described below. If you use a
short-named rule, the ’,’ separating the RULE from the MODIFIERS is optional. The PATTERN or FILENAME
that follows (when present) must come after either a single space or an underscore (_). Here are the
available rule prefixes:

exclude, - specifies an exclude pattern.
include, + specifies an include pattern.
merge, . specifies a merge-file to read for more rules.
dir-merge, : specifies a per-directory merge-file.
hide, H specifies a pattern for hiding files from the transfer.
show, S files that match the pattern are not hidden.
protect, P specifies a pattern for protecting files from deletion.
risk, R files that match the pattern are not protected.
clear, ! clears the current include/exclude list (takes no arg)

Note that the --include/--exclude command-line options do not allow the full range of rule parsing as
described above -- they only allow the specification of include/exclude patterns plus a "!" token to clear
the list (and the normal comment parsing when rules are read from a file). If a pattern does not begin
with "- " (dash, space) or "+ " (plus, space), then the rule will be interpreted as if "+ " (for an
include option) or "- " (for an exclude option) were prefixed to the string. A --filter option, on the
other hand, must always contain either a short or long rule name at the start of the rule.

Note also that the --filter, --include, and --exclude options take one rule/pattern each. To add multiple
ones, you can repeat the options on the command-line, use the merge-file syntax of the --filter option, or
the --include-from/--exclude-from options.

INCLUDE/EXCLUDE PATTERN RULES
You can include and exclude files by specifying patterns using the "+", "-", etc. filter rules (as intro‐
duced in the FILTER RULES section above). The include/exclude rules each specify a pattern that is
matched against the names of the files that are going to be transferred. These patterns can take several
forms:

o if the pattern starts with a / then it is anchored to a particular spot in the hierarchy of files,
otherwise it is matched against the end of the pathname. This is similar to a leading ^ in regular
expressions. Thus "/foo" would match a name of "foo" at either the "root of the transfer" (for a
global rule) or in the merge-file’s directory (for a per-directory rule). An unqualified "foo"
would match a name of "foo" anywhere in the tree because the algorithm is applied recursively from
the top down; it behaves as if each path component gets a turn at being the end of the filename.
Even the unanchored "sub/foo" would match at any point in the hierarchy where a "foo" was found
within a directory named "sub". See the section on ANCHORING INCLUDE/EXCLUDE PATTERNS for a full
discussion of how to specify a pattern that matches at the root of the transfer.

o if the pattern ends with a / then it will only match a directory, not a regular file, symlink, or
device.

o rsync chooses between doing a simple string match and wildcard matching by checking if the pattern
contains one of these three wildcard characters: ’*’, ’?’, and ’[’ .

o a ’*’ matches any path component, but it stops at slashes.

o use ’**’ to match anything, including slashes.

o a ’?’ matches any character except a slash (/).

o a ’[’ introduces a character class, such as [a-z] or [[:alpha:]].

o in a wildcard pattern, a backslash can be used to escape a wildcard character, but it is matched
literally when no wildcards are present.

o if the pattern contains a / (not counting a trailing /) or a "**", then it is matched against the
full pathname, including any leading directories. If the pattern doesn’t contain a / or a "**",
then it is matched only against the final component of the filename. (Remember that the algorithm
is applied recursively so "full filename" can actually be any portion of a path from the starting
directory on down.)

o a trailing "dir_name/***" will match both the directory (as if "dir_name/" had been specified) and
everything in the directory (as if "dir_name/**" had been specified). This behavior was added in
version 2.6.7.

Note that, when using the --recursive (-r) option (which is implied by -a), every subcomponent of every
path is visited from the top down, so include/exclude patterns get applied recursively to each subcompo‐
nent’s full name (e.g. to include "/foo/bar/baz" the subcomponents "/foo" and "/foo/bar" must not be
excluded). The exclude patterns actually short-circuit the directory traversal stage when rsync finds the
files to send. If a pattern excludes a particular parent directory, it can render a deeper include pat‐
tern ineffectual because rsync did not descend through that excluded section of the hierarchy. This is
particularly important when using a trailing ’*’ rule. For instance, this won’t work:

This fails because the parent directory "some" is excluded by the ’*’ rule, so rsync never visits any of
the files in the "some" or "some/path" directories. One solution is to ask for all directories in the
hierarchy to be included by using a single rule: "+ */" (put it somewhere before the "- *" rule), and per‐
haps use the --prune-empty-dirs option. Another solution is to add specific include rules for all the
parent dirs that need to be visited. For instance, this set of rules works fine:

+ /some/
+ /some/path/
+ /some/path/this-file-is-found
+ /file-also-included
- *

Here are some examples of exclude/include matching:

o "- *.o" would exclude all names matching *.o

o "- /foo" would exclude a file (or directory) named foo in the transfer-root directory

o "- foo/" would exclude any directory named foo

o "- /foo/*/bar" would exclude any file named bar which is at two levels below a directory named foo
in the transfer-root directory

o "- /foo/**/bar" would exclude any file named bar two or more levels below a directory named foo in
the transfer-root directory

o The combination of "+ */", "+ *.c", and "- *" would include all directories and C source files but
nothing else (see also the --prune-empty-dirs option)

o The combination of "+ foo/", "+ foo/bar.c", and "- *" would include only the foo directory and
foo/bar.c (the foo directory must be explicitly included or it would be excluded by the "*")

The following modifiers are accepted after a "+" or "-":

o A / specifies that the include/exclude rule should be matched against the absolute pathname of the
current item. For example, "-/ /etc/passwd" would exclude the passwd file any time the transfer
was sending files from the "/etc" directory, and "-/ subdir/foo" would always exclude "foo" when it
is in a dir named "subdir", even if "foo" is at the root of the current transfer.

o A ! specifies that the include/exclude should take effect if the pattern fails to match. For
instance, "-! */" would exclude all non-directories.
o A C is used to indicate that all the global CVS-exclude rules should be inserted as excludes in
place of the "-C". No arg should follow.

o An s is used to indicate that the rule applies to the sending side. When a rule affects the send‐
ing side, it prevents files from being transferred. The default is for a rule to affect both sides
unless --delete-excluded was specified, in which case default rules become sender-side only. See
also the hide (H) and show (S) rules, which are an alternate way to specify sending-side
includes/excludes.

o An r is used to indicate that the rule applies to the receiving side. When a rule affects the
receiving side, it prevents files from being deleted. See the s modifier for more info. See also
the protect (P) and risk ® rules, which are an alternate way to specify receiver-side
includes/excludes.

o A p indicates that a rule is perishable, meaning that it is ignored in directories that are being
deleted. For instance, the -C option’s default rules that exclude things like "CVS" and "*.o" are
marked as perishable, and will not prevent a directory that was removed on the source from being
deleted on the destination.

MERGE-FILE FILTER RULES
You can merge whole files into your filter rules by specifying either a merge (.) or a dir-merge (:) fil‐
ter rule (as introduced in the FILTER RULES section above).

There are two kinds of merged files -- single-instance (’.’) and per-directory (’:’). A single-instance
merge file is read one time, and its rules are incorporated into the filter list in the place of the "."
rule. For per-directory merge files, rsync will scan every directory that it traverses for the named
file, merging its contents when the file exists into the current list of inherited rules. These
per-directory rule files must be created on the sending side because it is the sending side that is being
scanned for the available files to transfer. These rule files may also need to be transferred to the
receiving side if you want them to affect what files don’t get deleted (see PER-DIRECTORY RULES AND DELETE
below).

The following modifiers are accepted after a merge or dir-merge rule:

o A - specifies that the file should consist of only exclude patterns, with no other rule-parsing
except for in-file comments.

o A + specifies that the file should consist of only include patterns, with no other rule-parsing
except for in-file comments.

o A C is a way to specify that the file should be read in a CVS-compatible manner. This turns on
’n’, ’w’, and ’-’, but also allows the list-clearing token (!) to be specified. If no filename is
provided, ".cvsignore" is assumed.

o An n specifies that the rules are not inherited by subdirectories.

o A w specifies that the rules are word-split on whitespace instead of the normal line-splitting.
This also turns off comments. Note: the space that separates the prefix from the rule is treated
specially, so "- foo + bar" is parsed as two rules (assuming that prefix-parsing wasn’t also dis‐
abled).

o You may also specify any of the modifiers for the "+" or "-" rules (above) in order to have the
rules that are read in from the file default to having that modifier set (except for the ! modi‐
fier, which would not be useful). For instance, "merge,-/ .excl" would treat the contents of .excl
as absolute-path excludes, while "dir-merge,s .filt" and ":sC" would each make all their per-direc‐
tory rules apply only on the sending side. If the merge rule specifies sides to affect (via the s
or r modifier or both), then the rules in the file must not specify sides (via a modifier or a rule
prefix such as hide).

Per-directory rules are inherited in all subdirectories of the directory where the merge-file was found
unless the ’n’ modifier was used. Each subdirectory’s rules are prefixed to the inherited per-directory
rules from its parents, which gives the newest rules a higher priority than the inherited rules. The
entire set of dir-merge rules are grouped together in the spot where the merge-file was specified, so it
is possible to override dir-merge rules via a rule that got specified earlier in the list of global rules.
When the list-clearing rule ("!") is read from a per-directory file, it only clears the inherited rules
for the current merge file.

Another way to prevent a single rule from a dir-merge file from being inherited is to anchor it with a
leading slash. Anchored rules in a per-directory merge-file are relative to the merge-file’s directory,
so a pattern "/foo" would only match the file "foo" in the directory where the dir-merge filter file was
found.

Here’s an example filter file which you’d specify via --filter=". file":

If a per-directory merge-file is specified with a path that is a parent directory of the first transfer
directory, rsync will scan all the parent dirs from that starting point to the transfer directory for the
indicated per-directory file. For instance, here is a common filter (see -F):

That rule tells rsync to scan for the file .rsync-filter in all directories from the root down through the
parent directory of the transfer prior to the start of the normal directory scan of the file in the direc‐
tories that are sent as a part of the transfer. (Note: for an rsync daemon, the root is always the same
as the module’s "path".)

Some examples of this pre-scanning for per-directory files:

rsync -avF /src/path/ /dest/dir
rsync -av --filter=': ../../.rsync-filter' /src/path/ /dest/dir
rsync -av --filter=': .rsync-filter' /src/path/ /dest/dir

The first two commands above will look for ".rsync-filter" in "/" and "/src" before the normal scan begins
looking for the file in "/src/path" and its subdirectories. The last command avoids the parent-dir scan
and only looks for the ".rsync-filter" files in each directory that is a part of the transfer.

If you want to include the contents of a ".cvsignore" in your patterns, you should use the rule ":C",
which creates a dir-merge of the .cvsignore file, but parsed in a CVS-compatible manner. You can use this
to affect where the --cvs-exclude (-C) option’s inclusion of the per-directory .cvsignore file gets placed
into your rules by putting the ":C" wherever you like in your filter rules. Without this, rsync would add
the dir-merge rule for the .cvsignore file at the end of all your other rules (giving it a lower priority
than your command-line rules). For example:

cat <<EOT | rsync -avC --filter='. -' a/ b
+ foo.o
:C
- *.old
EOT
rsync -avC --include=foo.o -f :C --exclude='*.old' a/ b

Читайте также: