<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Unable to copy mutiple files from file:/tmp to dbfs:/tmp in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/unable-to-copy-mutiple-files-from-file-tmp-to-dbfs-tmp/m-p/16323#M10524</link>
    <description>Thanks Deepak&lt;BR /&gt;This is what I have suspected.&lt;BR /&gt;Hopefully the wild card feature might be available in future&lt;BR /&gt;Thanks</description>
    <pubDate>Thu, 16 Sep 2021 18:10:01 GMT</pubDate>
    <dc:creator>hoopla</dc:creator>
    <dc:date>2021-09-16T18:10:01Z</dc:date>
    <item>
      <title>Unable to copy mutiple files from file:/tmp to dbfs:/tmp</title>
      <link>https://community.databricks.com/t5/data-engineering/unable-to-copy-mutiple-files-from-file-tmp-to-dbfs-tmp/m-p/16320#M10521</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I am downloading multiple files by web scraping and by default they are stored in /tmp&lt;/P&gt;
&lt;P&gt;I can copy a single file by providing the filename and path &lt;/P&gt;&lt;P&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;%fs cp file:/tmp/2020-12-14_listings.csv.gz dbfs:/tmp&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but when I try to copy multiple files I get an error&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;%fs cp file:/tmp/*_listings* dbfs:/tmp&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Error&lt;/P&gt;
&lt;P&gt;&lt;B&gt;FileNotFoundException: File file:/tmp/&lt;I&gt;_listings&lt;/I&gt; does not exist&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;Hoping someone has seen this before 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 01:52:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/unable-to-copy-mutiple-files-from-file-tmp-to-dbfs-tmp/m-p/16320#M10521</guid>
      <dc:creator>hoopla</dc:creator>
      <dc:date>2021-08-18T01:52:59Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to copy mutiple files from file:/tmp to dbfs:/tmp</title>
      <link>https://community.databricks.com/t5/data-engineering/unable-to-copy-mutiple-files-from-file-tmp-to-dbfs-tmp/m-p/16322#M10523</link>
      <description>&lt;P&gt;Wildcards are currently not supported with dbutils. You can move the whole directory:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;dbutils.fs.mv("file:/tmp/test", "dbfs:/tmp/test2", recurse=True)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;or just a single file:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;dbutils.fs.mv("file:/tmp/test/test.csv", "dbfs:/tmp/test2/test2.csv")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Since the wildcards are not allowed, we need to make it work in this way (list the files and then move or copy - slight traditional way)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import os
&amp;nbsp;
def db_list_files(file_path, file_prefix):
  file_list = [file.path for file in dbutils.fs.ls(file_path) if os.path.basename(file.path).startswith(file_prefix)]
  return file_list
&amp;nbsp;
files = db_list_files('file:/your/src_dir', 'foobar')
&amp;nbsp;
for file in files:
  dbutils.fs.cp(file, os.path.join('dbfs:/your/tgt_dir', os.path.basename(file)))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 12:15:52 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/unable-to-copy-mutiple-files-from-file-tmp-to-dbfs-tmp/m-p/16322#M10523</guid>
      <dc:creator>Deepak_Bhutada</dc:creator>
      <dc:date>2021-09-15T12:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to copy mutiple files from file:/tmp to dbfs:/tmp</title>
      <link>https://community.databricks.com/t5/data-engineering/unable-to-copy-mutiple-files-from-file-tmp-to-dbfs-tmp/m-p/16323#M10524</link>
      <description>Thanks Deepak&lt;BR /&gt;This is what I have suspected.&lt;BR /&gt;Hopefully the wild card feature might be available in future&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 16 Sep 2021 18:10:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/unable-to-copy-mutiple-files-from-file-tmp-to-dbfs-tmp/m-p/16323#M10524</guid>
      <dc:creator>hoopla</dc:creator>
      <dc:date>2021-09-16T18:10:01Z</dc:date>
    </item>
  </channel>
</rss>

